Skip to content

Instantly share code, notes, and snippets.

View snodgrass23's full-sized avatar

Jim Snodgrass snodgrass23

  • North Carolina
View GitHub Profile
@snodgrass23
snodgrass23 / restfuljsapp.sh
Created October 3, 2012 19:34
Create new restfulsjs app
npm install restfuljs -g
restfuljs app -d myNewApp -w 'users, projects'
@snodgrass23
snodgrass23 / testFile.js
Created November 7, 2012 14:50
verifyjs analysis output
var foo = bar
less = more;
function complexFunction(one, two, three, four, five, six) {
if (one) {
}
else if (two) {
var hello;
@snodgrass23
snodgrass23 / errors.js
Created November 11, 2012 15:34
analysis errors
[ { id: '(error)',
raw: 'Expected \'{a}\' and instead saw \'{b}\'.',
evidence: ' if (val === \'Recently Active\') search.sort.lastLogin = -1;',
line: 58,
character: 34,
scope: '(main)',
a: '{',
b: 'search',
c: undefined,
d: undefined,
@snodgrass23
snodgrass23 / branch.rb
Last active December 14, 2015 01:48
rails "or" query with near
remote_query = root.remote_opportunities_available?(company_type).where_values.last.to_sql
location_query = root.near(params[:location], params[:radius] || BranchSearch::DEFAULT_SEARCH_RADIUS).where_values.last
res = root.where(remote_query + " OR " + location_query)
@snodgrass23
snodgrass23 / node_speed_test.js
Last active December 15, 2015 00:29
speed test comparisons for Node and Ruby
function getRands(i) {
var r = [];
while (i--) {
r[i] = Math.floor(Math.random() * 5);
}
return r;
}
function findMatchScore(profileDimensions, verseDimensions) {
var i = profileDimensions.length;
@snodgrass23
snodgrass23 / gist:5360536
Created April 11, 2013 03:34
Example of Heroku email hooks adding escapes to all backslashes (in this case nullifying new line characters).
{{user}} deployed2 {{head}} to {{url}}\\\\\\\\r\\\\\\\\n\\\\\\\\r\\\\\\\\n{{git_log}}
@snodgrass23
snodgrass23 / gist:7270490
Created November 1, 2013 19:19
bash profile
PROMPT_COMMAND='DIR=`pwd|sed -e "s!$HOME!~!"`; if [ ${#DIR} -gt 30 ]; then CurDir=${DIR:0:12}...${DIR:${#DIR}-15}; else CurDir=$DIR; fi'
PS1="[\$CurDir] \$ "
alias c="mate ~/.bash_profile"
alias r=". ~/.bash_profile"
alias l="ls -la"
alias push="git push origin master"
alias pull="git pull origin master"
alias commit="git add .; git commit -m"
@snodgrass23
snodgrass23 / gameTurns
Created January 31, 2014 05:05
gameTurns
[
{
"grid": "................................................................................................................................................................................................................................................................................................................................................................................................................",
"p2": {
"spawn": 378,
"energy": 1
},
"p1": {
"spawn": 21,
"energy": 1
@snodgrass23
snodgrass23 / app.js
Created February 20, 2014 18:30
stream server
http.createServer(function (req, res) {
var buffer = '';
req
.on('data', function(buf) {
buffer += buf.toString();
})
.on('end', function() {
if (!buffer) return res.end('Jimbot with roles');
var data = JSON.parse(qs.parse(buffer).data);
console.log("\n............ turn : ", data.state.turnsElapsed + 1, '...............\n');
@snodgrass23
snodgrass23 / gist:11044849
Created April 18, 2014 13:42
newton notes
  • docs don't mention the html needs (example needs canvas element)
  • order matters for some methods, but beginning of docs doesn't make it clear until looking at a full demo
  • first example doesn't work with viewport method which I added earlier by following the docs in order (looks like none of examples use viewport after first mentioning it).
  • explain linear force/gravity example better. maybe define vars first with names explaining what those numbers mean or just use inline comment like in many other examples
  • better code docs for inline autocompletion?
  • spring example doesn't work (SpringConstraint not defined)
  • many numbers used (x,y, etc) don't work with one another well when working through the docs in order