Jump to content

Pinguinsan

Member
  • Posts

    193
  • Joined

  • Last visited

Reputation Activity

  1. Like
    Pinguinsan got a reaction from SkilledRebuilds in What's That Song With The Melody That Sounds Like Rubber Chickens   
    Hey guys,
     
    I have heard a song one or two times in the past two months or so. I'm not sure which Spotify channel it was on (it could be a newer song, it could be an older song). The only thing I can remember about it is that the melody in the song is very frantic, and it vaguely sounds like rubber chickens or some kind of horn. I don't remember if there are any lyrics to it.
     
    If it was played often, I could just use Shazam (or whatever), but it doesn't play often and it's driving me nuts. I have tried Googling everything from "song that sounds like rubber chickens" to "song with very frantic pace"
     
    Does anyone have any ideas or does this ring a bell?
     
    Thanks,
    -Tyler
  2. Like
    Pinguinsan got a reaction from RileyTheFox in How to see if a field has an Enum applied to it? (C#)   
    using System; namespace FlagsTest { internal class Program { //Ensure [Flags] attribute to allow bitwise testing //Also use 1 bitshifting to ensure flags are powers of 2 (1, 2, 4, 8, etc) [Flags] public enum Flags : byte { NONE = (1 << 0), CHORD = (1 << 1), EXTENDEDSUSTAIN = (1 << 2), STAR_POWER = (1 << 3), STAR_POWER_END = (1 << 4), SOLO_BEGIN = (1 << 5), SOLO_END = (1 << 6), DOUBLED = (1 << 7) } //Older (.NET Framework pre-4.0) private static void testFlagsOldMethod(Flags flag) { var hadChord = (flag & Flags.CHORD) == Flags.CHORD; var hasExtendedSustain = (flag & Flags.EXTENDEDSUSTAIN) == Flags.EXTENDEDSUSTAIN; var hasStarPower = (flag & Flags.STAR_POWER) == Flags.STAR_POWER; var hasStarPowerEnd = (flag & Flags.STAR_POWER_END) == Flags.STAR_POWER_END; var hasSoloBegin = (flag & Flags.SOLO_BEGIN) == Flags.SOLO_BEGIN; var hasSoloEnd = (flag & Flags.SOLO_END) == Flags.SOLO_END; var hasDoubled = (flag & Flags.DOUBLED) == Flags.DOUBLED; Console.WriteLine("Flag.CHORD? {0}", hadChord); Console.WriteLine("Flag.EXTENDEDSUSTAIN? {0}", hasExtendedSustain); Console.WriteLine("Flag.STAR_POWER? {0}", hasStarPower); Console.WriteLine("Flag.STAR_POWER_END? {0}", hasStarPowerEnd); Console.WriteLine("Flag.SOLO_BEGIN? {0}", hasSoloBegin); Console.WriteLine("Flag.SOLO_END? {0}", hasSoloEnd); Console.WriteLine("Flag.DOUBLED? {0}", hasDoubled); } //Newer (.NET Framework 4.0 and newer) private static void testFlagsNewMethod(Flags flag) { var hadChord = flag.HasFlag(Flags.CHORD); var hasExtendedSustain = flag.HasFlag(Flags.EXTENDEDSUSTAIN); var hasStarPower = flag.HasFlag(Flags.STAR_POWER); var hasStarPowerEnd = flag.HasFlag(Flags.STAR_POWER_END); var hasSoloBegin = flag.HasFlag(Flags.SOLO_BEGIN); var hasSoloEnd = flag.HasFlag(Flags.SOLO_END); var hasDoubled = flag.HasFlag(Flags.DOUBLED); Console.WriteLine("Flag.CHORD? {0}", hadChord); Console.WriteLine("Flag.EXTENDEDSUSTAIN? {0}", hasExtendedSustain); Console.WriteLine("Flag.STAR_POWER? {0}", hasStarPower); Console.WriteLine("Flag.STAR_POWER_END? {0}", hasStarPowerEnd); Console.WriteLine("Flag.SOLO_BEGIN? {0}", hasSoloBegin); Console.WriteLine("Flag.SOLO_END? {0}", hasSoloEnd); Console.WriteLine("Flag.DOUBLED? {0}", hasDoubled); } public static void Main(string[] args) { var testFlags = Flags.NONE; testFlags |= Flags.DOUBLED; testFlags |= Flags.STAR_POWER; testFlagsOldMethod(testFlags); Console.WriteLine(); testFlagsNewMethod(testFlags); } } }  
  3. Like
    Pinguinsan got a reaction from mrchow19910319 in Simple JS code.   
    If you're using Chrome or Firefox, you can test it yourself. Press F12 and click on "Console" in the developer window. Then paste that program inline:
     
    function foo(b) { var a = 5; return a*b+10 } function bar(x) { var y = 3; return foo(x*y); } console.log(bar(6)) and hit enter. Should print out 100 as written.
  4. Like
    Pinguinsan reacted to Nuluvius in Make button direct to link java   
    Nope. You should be using IntelliJ.
  5. Agree
    Pinguinsan reacted to Dat Guy in C++ help !   
    Briefly looked at the source code:
     
    using namespace std; Ugh. Don't.
     
    Also, this code is amazingly horrible to read thanks to virtually no meaningful indentation.
     

     
    ... u wat m8?
  6. Agree
    Pinguinsan reacted to Nuluvius in C++ help !   
    Oh look it's another one of those 'do my homework for me while I contribute absolutely 0 effort' threads.
     
    How about no.
  7. Like
    Pinguinsan got a reaction from yuh25 in Statements that shouldn't be printed are printing. (C++14)   
    Clearly not, because he's asking the question.

    In the constructor, you need to set the member "age" variable to the initialAge that is passed in. So change 
     
    if (initialAge > 0) { initialAge = age; } To
    if (initialAge > 0) { age = initialAge; } So that age stores the initialAge passed into the constructor.
  8. Agree
    Pinguinsan got a reaction from LePawel in Writing Joke Virus Application   
    Use a bunch of the lines from Weird Al's Virus Alert
  9. Like
    Pinguinsan got a reaction from CookieMaster in ignore, solved by self   
    Ah, sorry about that, I was looking at the documentation for QGraphicsScene, not QGraphicsView. Yeah, it looks like your method works will work (does it?).
  10. Informative
    Pinguinsan got a reaction from CookieMaster in ignore, solved by self   
    void MainWindow::on_close_clicked() { ui->graphicsView->clear(); ui->graphicsView->viewPort().update(); } The viewPort update may or may not be necessary, see here
  11. Like
    Pinguinsan got a reaction from ClobberXD in Unable to use std::thread - Part 2   
    Yep, you got it! One of the weird things that you don't really learn anywhere is why the "this" keyword is available in every member function, and it's because when you have a class member like:
    class MyClass { public: void Func(); }; The ACTUAL signature to the member, generated by the compiler is
    class MyClass { public: void Func(MyClass *this); }; And any time you call from any other class method, the compiler automatically adds the "this" pointer, so you don't have to:
     
    void MyClass { public: void OtherFunc() { this->Func(); //Notice I don't need to include "this" when calling Func() } void Func() { } }; And indeed, you can't include the "this" pointer even if you wanted to, as it is implicit the the compiler.
  12. Agree
    Pinguinsan reacted to Unimportant in Unable to use std::thread - Part 2   
    And the reason, should anyone be interested, is that a instance of a class only contains the class's data (*). You can test this:
    class Foo { int bar; public: // Add as much member functions as you like ... }; //You'll always get this... sizeof(Foo) == sizeof(int) If you have a million instances of this class you'll have a million int's, but the code for the member functions will exist only once, because it is always the same, only the data of a class changes.
    That means, under the hood, this code must always receive a pointer to the instance data to work on.
     
    (*) With some possible exceptions, such as a polymorphic class, which will probably also contain a vtable or some other extra data for the runtime dispatch mechanism.
  13. Like
    Pinguinsan got a reaction from ClobberXD in Unable to use std::thread - Part 2   
    You must use pointer-to-member-function syntax when passing an instance level method (ie non-static, tied to an instance of MyClass), as well as the "this" pointer when creating a std::thread to an instance level member function.So change
    std::thread t(&Func); to
    std::thread t(&MyClass::Func, this);
  14. Agree
    Pinguinsan reacted to stmfd sp!, {lr} in C++ for loop   
    Important note:
    It will actually deduce: std::pair<const TKey, TValue>.
     
    Which is another way that auto will save your ass. Since, if you used a range-based for loop with a map declared with, say, std::map<int, char> and tried to iterate it with a const reference to std::pair<int, char>, each iteration will produce a copy since the constness cast will be implicit. That's why using auto is a nice way to avoid situations where code that looks intuitive will actually produce implicit casts (and, therefore, copies).
     
    Sorry for being pedantic.
  15. Agree
    Pinguinsan reacted to Unimportant in C++ for loop   
    Just as a interesting FYI for those who care:
    One should be able to write:
    isDivisibleBy(test, 2); Template type deduction should do the rest and remove the need for the explicit <int, int>.
  16. Like
    Pinguinsan got a reaction from Merkey in Python or C for Raspberry PI 3?   
    As everyone else has said, it depends on what you want to do. The Raspberry Pi ships with Python GPIO support out of the box (or with an apt-package, I can't remember), but it's equally easy to install wiringPi and use the arduino-style interface.
  17. Like
    Pinguinsan got a reaction from leonfagan71 in flash drive mount script   
    AKA Windows programming
  18. Funny
    Pinguinsan reacted to dany_boy in Bell System Replaced With Music?   
    There are literally hundreds of ways of automating such a thing as a school bell. You are gonna have to be more specific on requirements
  19. Informative
    Pinguinsan reacted to fizzlesticks in Review for C# style String.Format() in C++   
    Because they're template arguments, doing
    template <typename First, typename ... Args> std::string TStringFormat(const char *formatting, First&& first, Args&& ... args) Would make them forwarding-references / universal-references, not rvalue references. It would be beneficial for any type that could be converted to a string by moving. So for a std::string you would do a move instead of a copy and user defined types would be able to take advantage of it. For example, if you wanted a Book to be toStdString-able and the string is just the title of the book you could have the overload:
    std::string toStdString(Book&& rhs) { return std::move(rhs.title); }  
     
    Also I don't know if it was intentional but your function is inconsistent for strings with recursive "{x}"s. 
    std::cout << TStringFormat("{0} {1}", "{1}", 20); //outputs "20 20" std::cout << TStringFormat("{0} {1}", "{10}", 20); //ouputs "{10} 20" I would expect either the first to output "{1} 20" or the second to throw an index out of range exception depending on if you want to allow recursive look ups or not.
  20. Agree
    Pinguinsan reacted to fizzlesticks in Review for C# style String.Format() in C++   
    You're missing #include <sstream>
     
    The static_cast<std::string>s in toStdString are unnecessary. They will basically get transformed into static_cast<std::string>(std::string(rhs)); making the cast pointless. If you want to be explicit about it, just doing return std::string(rhs); would be better.
     
    The parameters for TStringFormat should all be const.
     
  21. Funny
    Pinguinsan got a reaction from Factory OC in Sketchiest DIY Heatsink EVER   
    Holy shit, "JUST RAW DOG IT"

    I'm dead
     
    lmfao
  22. Informative
    Pinguinsan got a reaction from Dobbsjr in Can anyone show me an example of a delegate and an event?   
    namespace DelegateTest { public class Car { //Note, delegate and event must have the exact same name public delegate void PositionChanged(int newPosition); public event PositionChanged positionChangedEvent; private int m_position; public Car() { this.m_position = 0; //car is at position 0 } public void driveToPosition(int position) { if (this.m_position != position) //check if position changed { this.m_position = position; //Always check event for null before triggering the event if (this.positionChangedEvent != null) { this.positionChangedEvent.Invoke(this.m_position); } } } } public class Program { static void Main(string[] args) { Car car = new Car(); car.positionChangedEvent += Program.onCarPositionChanged; //Hook/subscribe to the event car.driveToPosition(15); car.driveToPosition(200); car.driveToPosition(0); car.driveToPosition(0); //Will not fire event, because no change in position car.driveToPosition(10); Console.ReadKey(); //Pause console to see output //...etc } //Note that the receiving function must have the same type signature as the delegate/event private static void onCarPositionChanged(int newPosition) { Console.WriteLine("The car moved to position {0}", newPosition); } } }  
  23. Like
    Pinguinsan got a reaction from Dat Guy in Need help manipulating strings in C.   
    Yes it would.
    #include <stdio.h> #include <string.h> #include <stdlib.h> #define ARRAY_SIZE(x) sizeof(x)/sizeof(x[0]) int main() { char first[] = "Hello, World"; char *second = (char *)calloc(ARRAY_SIZE(first), sizeof(char)); strncpy(second, first, ARRAY_SIZE(first)); printf("first = %s, second = %s\n", first, second); free(second); //Make sure to free all calloc'd or malloc'd memory } pinguinsan@Z170A-Titanium-PC:~$ ./test first = Hello, World, second = Hello, World  
  24. Like
    Pinguinsan got a reaction from Blade of Grass in How to make a array of pointers?   
    Of course when passing a non-pointer type to a function, it will create a local stack copy. My comment was regarding using an "array" as an argument to a function, not for passing regular types.

    And yes, while you are technically correct that C does not pass by reference (a function taking a pointer as an argument takes the value of the pointer), everyone knows what you mean when you say it.
    "pass by reference".
  25. Informative
    Pinguinsan got a reaction from mathijs727 in How to make a array of pointers?   
    This is correct, and bound to bite every beginner C and C++ programmer sooner or later, especially when trying to pass arrays to functions. See below:
    #include <stdio.h> #define ARRAY_SIZE(x) sizeof(x)/sizeof(x[0]) //Deceiving, because (EDIT: pointer/array) arguments to functions are ALWAYS //simply pointers, NOT arrays void arraySize(char charArray[]) { printf("ARRAY_SIZE(charArray) = %zu\n", ARRAY_SIZE(charArray)); //Prints 4! } int main() { char myCharPointer[50]; //Allocates an array of size 50 on the stack printf("ARRAY_SIZE(myCharPtr) = %zu\n", ARRAY_SIZE(myCharPointer)); //Prints 50 arraySize(myCharPointer); }  
×