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 <stdio.h> | |
| #include <stdlib.h> | |
| #include <limits.h> | |
| #include <errno.h> | |
| #define SIZE 4 | |
| int main(int argc, char **argv) { | |
| char *basic = "8887"; | |
| char *dataStr = "1234 1a2b3c4e -10101010 0xdeadbeef"; | |
| char *endPtr = dataStr; |
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
| using System; | |
| using System.Collections; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| using System.Xml; | |
| using System.Xml.Linq; | |
| using System.Xml.XPath; | |
| using System.Reflection; |
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
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| namespace Program { | |
| public class NodeThing<T> { | |
| public T Value; | |
| public NodeThing() { } |
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
| #!/usr/bin/env bash | |
| { code=$(</dev/fd/0); } <<\EOF | |
| ${ZSH_VERSION+false} || emulate ksh | |
| # eval showEnv (funcname) to display the state of "x" from a subprocess. | |
| showEnv=$'bash -c \'${x+:} typeset x=unset; printf "subprocess %s: %s\\n" "$1" "$(typeset -p x)"\' --' | |
| function printTest { | |
| printf '%s test %d:\n' "$1" $((testnum++)) >&2 |
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
| public static string GetKeyFromRecord<T>(IEnumerable<string> pRecordProps) where T : HashAlgorithm, new() { | |
| using (T hashAlg = new T()) { | |
| IEnumerable<byte> result = pRecordProps | |
| .Select(x => hashAlg.ComputeHash(Encoding.UTF8.GetBytes(x ?? string.Empty))) | |
| .SelectMany(y => y); | |
| return Convert.ToBase64String(hashAlg.ComputeHash(result.ToArray())); | |
| } | |
| } |
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
| #!/usr/bin/env bash | |
| # bash / ksh93 / mksh / zsh | |
| # Don't do this! | |
| ${ZSH_VERSION+false} || emulate ksh | |
| unset -v isKsh93 | |
| [[ ${!KSH_VERSION} == .sh.version ]] && isKsh93= | |
| # Reads lines from file or stdin into arrayName, stupidly. | |
| # evilReadLines arrayName [ file ] |
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
| #!/usr/bin/env ksh | |
| typeset -a FUNCNAME | |
| function FUNCNAME.get { | |
| nameref self=${.sh.name} | |
| if (( .sh.subscript < .sh.level )); then | |
| trap "(( .sh.level -= .sh.subscript + 1 )); eval '(( .sh.level = ${.sh.level} ))' \; _=\${.sh.fun}" DEBUG | |
| trap - DEBUG; | |
| fi |
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
| #!/usr/bin/env ksh | |
| # Example for merging directories of files with possibly | |
| # overlapping names into a single directory. | |
| mkdir a b c new | |
| touch a/{0..5} b/{3..7} c/{4..10} | |
| echo before: */* | |
| typeset -A files | |
| for x in ~(N)./*/*; do |
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
| bash -xO expand_aliases <<\EOF | |
| alias magic='x=${BASH_COMMAND#"${BASH_ALIASES[magic]} "} command eval cmd=\$x \#' | |
| magic oh hi there | |
| printf 'The command that would have evaluated is: "%s"\n' "$cmd" | |
| EOF |