This file contains 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/bash | |
let count0=0 | |
for f in $(ls ./tests/*.txt); do | |
./a.out 0 < $f > ./tests/`basename $f .txt`.output; | |
diff -Bw ./tests/`basename $f .txt`.output ${f}.expected > ./tests/`basename $f .txt`.diff; | |
done; | |
for f in $(ls tests/*.txt); do | |
echo "========================================================"; |
This file contains 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
function median($arr){ | |
if($arr){ | |
$count = count($arr); | |
sort($arr); | |
$mid = floor($count/2); | |
return ($arr[$mid]+$arr[$mid+1-$count%2])/2; | |
} | |
return false; | |
} | |
function average($arr){ |
This file contains 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
## ATTN: run in ELEVETED powershell OR run as ADMINISTRATOR | |
## C:>\ powershell.exe | |
## PS C:>\ .\gen_machine_key.ps1 | |
## copy output into your web.config > <system.web> | |
# Generates a <machineKey> element that can be copied + pasted into a Web.config file. | |
function Generate-MachineKey { | |
[CmdletBinding()] | |
param ( | |
[ValidateSet("AES", "DES", "3DES")] |
This file contains 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/bash | |
# script for cloning repos from org | |
# and setting up remotes | |
# must have existing fork of target repo | |
if [ "$#" -ne 2 ]; then | |
echo "Usage: clone_repo.sh <git username> <repository name>" | |
else | |
git clone https://www.github.com/"$1"/"$2".git "$2" |
This file contains 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/bash | |
HELPTEXT=`cat <<EOF | |
This script will neatly package your java project. | |
Recommended Project Structure | |
.. compile_run.sh bin lib src | |
Options: | |
-t|--target [string] the fully qualified name of the main class | |
-s|--standalone [flag] compile all dependencies into the final jar |
This file contains 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
import React, { Component } from 'react'; | |
export class Mouse extends React.Component { | |
state = { x: 0, y: 0 }; | |
onMouseMove = (event) => { | |
this.setState( | |
{ x: event.clientX, y: event.clientY } | |
); | |
}; |
This file contains 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> | |
int countSubstr(char string[], char substring[]) | |
{ | |
int count = 0; | |
size_t i = -1; | |
while(string[++i]) | |
{ | |
int match = 1; | |
size_t j = 0; |
This file contains 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
var scripts = [ | |
'https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js', | |
'https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js' | |
]; | |
scripts.forEach(source => { | |
var script = document.createElement('script'); | |
script.src = source; | |
document.getElementsByTagName('head')[0].appendChild(script); | |
}); |
This file contains 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
/** | |
* the stupidest way I could imagine to paginate | |
* an input array by pages with pageSize | |
*/ | |
const paginate = (data, pageSize) => [ | |
...Array(~~((data || []).length/pageSize)).keys() | |
].map(i => data.slice(i*pageSize , (i+1)*pageSize )); | |
// ~~ // floors a number | |
// [...Array(n).keys] => [0, 1, 2, ..., n - 2, n - 1] |
This file contains 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
############################################################# | |
# lotto.py | |
############################################################# | |
# Description: Compare avg return of 2018-10-23 | |
# mega million lottery compared to number of tickets bought. | |
# Note: this script doesn't appear to implement the correct | |
# behavior for doing so. I think my math is off. Oh well, it | |
# was fun trying. | |
############################################################# |