This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Example from Bjarne Stroustrup's Programming | |
| #include <iostream> | |
| using namespace std; | |
| void swap_v(int a, int b) | |
| { int temp; temp = a, a = b; b = temp; } | |
| void swap_r(int& a, int& b) | |
| { int temp; temp = a, a = b; b = temp; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::str::FromStr; | |
| #[derive(Debug)] | |
| enum Version { Version1, Version2 } | |
| #[derive(Debug)] | |
| enum ParseError { InvalidSyntax, UnsupportedVersion } | |
| fn parse_version(line: String) -> Result<Version, ParseError> { | |
| let mut split = line.split("="); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::str::FromStr; | |
| #[derive(Debug)] | |
| enum Version { Version1, Version2 } | |
| #[derive(Debug)] | |
| enum ParseError { InvalidSyntax, UnsupportedVersion } | |
| struct NameValue { | |
| name: String, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DigitCounter { | |
| public static int getCountsOfDigits(int n) | |
| { | |
| if (n > 999999999) | |
| return 10; | |
| if (n > 99999999) | |
| return 9; | |
| if (n > 9999999) | |
| return 8; | |
| if (n > 999999) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdlib.h> | |
| #define unlikely_custom(p) (!!(p)) | |
| char* f() { | |
| char *ppsz_ret; | |
| ppsz_ret = malloc(sizeof(char *) * 12); | |
| if (! ! (!ppsz_ret)) | |
| return NULL; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /bin/sh | |
| test -n "$srcdir" || srcdir=`dirname "$0"` | |
| test -n "$srcdir" || srcdir=. | |
| ( | |
| cd "$srcdir" && | |
| autoreconf --force -v --install | |
| ) || exit | |
| test -n "$NOCONFIGURE" || "$srcdir/configure" "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://codetheory.in/get-application-apk-file-from-android-device-to-your-computer/ | |
| adb shell pm list packages | |
| # Output: | |
| # package:org.coursera.android | |
| # package:com.quizup.core | |
| # package:com.airbnb.android | |
| adb shell pm path com.airbnb.android | |
| # Output: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| source=$1 | |
| if [ -z $source ]; then | |
| echo "usage: $0 filename.wct > filename.bin" | |
| exit 1 | |
| fi | |
| cat "$source" | tr ABCDEFGHIJKLMNPO 0123456789abcdef | xxd -r -p |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::io::prelude::*; | |
| use std::io::BufReader; | |
| use std::fs::File; | |
| fn get_dimensions(line: String) -> Vec<i32> { | |
| line.split('x').map(|x| x.parse::<i32>().unwrap()).collect::<Vec<i32>>() | |
| } | |
| fn how_many_paper() -> i32 { | |
| let f = File::open("input").unwrap(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <future> | |
| #include <map> | |
| using namespace std; | |
| template <class T> | |
| struct problem { | |
| promise<shared_future<T> > p; | |
| shared_future<shared_future<T> > f; |