Skip to content

Instantly share code, notes, and snippets.

@Nogbit
Nogbit / dial.js
Last active October 7, 2018 17:15
SVG.JS Composite Elements
SVG.Dial = SVG.invent({
create: 'g',
inherit: SVG.Group,
construct: {
dial: function (config) {
this.box1 = (new SVG.Rect()).size(100, 100).fill('#fff')
this.box2 = (new SVG.Rect()).size(75, 75).fill('#F9AE30')
@Nogbit
Nogbit / logstoslack.sh
Created April 27, 2018 16:34
node logs to slack
#!/bin/bash
APP_NAME=""
SERVER="$HOSTNAME:fosterservices/bin/appChecker"
APP_LOG=""
SLACK_URL="https://hooks.slack.com/services/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"
SLACK_CHANNEL="#integrations"
SLACK_ICON_SUCCESS=":up:"
SLSCK_ICON_FAIL=":sos:"
OPT_ERR="Please specify log file to proccess with the -f option."
LOG_WARN=""
@Nogbit
Nogbit / GitFlow.md
Last active October 12, 2017 16:06

Please use Git Flow with the exception of the Release branch (not needed for us). This page is very specific as what to do and when.

PRE REQ - UPDATE CONFIG

Add the following to ~/.gitconfig. This is required for these commands below and to make sure we are consistent in helping each other out.

[color]
    ui = auto
  [color "branch"]

Getting the VS project to build can be tricky, especially if you built the 64bit version of GLEW by accident. Anyways, this uses binaries and VS 2015. http://www.learnopengl.com/#!Getting-started/Hello-Window

  1. Make a new folder, OpenGL
  2. Download GLEW, binaries, extract to your new OpenGL folder http://glew.sourceforge.net/
  3. Download GLFW, 32 bit binaries, extract to your new OpenGL folder http://www.glfw.org/download.html
  4. Start a new empty C++ project in VS 2015
  5. Right click on your project, then "properties - C/C++ - General"
  6. Select "Additional Include Directories"
  7. In the following steps, replace [your path] with the path to your newly created OpenGL folder
  8. Now lets get VS to find the header files that you just downloaded to your new OpenGL folder...
@Nogbit
Nogbit / static-methods.rs
Last active March 23, 2016 04:46
Rust - Builder Pattern
// https://doc.rust-lang.org/book/method-syntax.html#builder-pattern
struct Circle {
x: f64,
y: f64,
radius: f64,
}
impl Circle {
fn area(&self) -> f64 {
@Nogbit
Nogbit / factory.js
Last active January 26, 2016 07:37
ES6 Factory Function Example
//https://medium.com/javascript-scene/common-misconceptions-about-inheritance-in-javascript-d5d9bab29b0a#.2ibda6ur8
let animal = {
animalType: 'animal',
describe () {
return `An ${this.animalType} with ${this.furColor} fur,
${this.legs} legs, and a ${this.tail} tail.`;
}
};
@Nogbit
Nogbit / 001_migration.rb
Last active August 29, 2015 14:25
Associations upgrade to Sequel from DataMapper
# 001_migration.rb was auto generated via sequel from a Database that was created by DataMapper models.
# There were a lot of other properties on the migration, I remove them for simplicity here
Sequel.migration do
change do
create_table(:groups) do
String :id, :size=>40, :null=>false
Integer :school_id, :null=>false
String :ems_type, :size=>20, :null=>false
@Nogbit
Nogbit / gist:759d4d271f3bb2a5983c
Last active August 29, 2015 14:25
Sequel with snake case to camel case model props
require 'sequel'
class String
def camel_case
s = camelize
s[0] = s[0].downcase
s
end
end
module Sinatra
var file = path.join(process.cwd(), 'fixtures/scrubbed/source/term_current');
var data = fs.readFileSync(file, 'utf8');
var scrubbed = data.replace(/(['"])?([a-zA-Z0-9_]+)(['"])?:/g, '"$2": ');
console.log(JSON.parse(scrubbed));
app.use(session({
secret: fs.readFileSync(config.secretFile, 'utf-8'),
cookie: {secret: true, secure: true, httpOnly: false},
resave: false,
saveUninitialized: true
}));