Skip to content

Instantly share code, notes, and snippets.

@bycoffe
bycoffe / csvtosqlite.py
Created October 23, 2009 16:52
Creates a sqlite database and table from a CSV file for easier querying
"""
Copyright (c) 2009, Aaron Bycoffe
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
# Bikes Factory
b1 = {brand: "scott", year: 2016, color: "red"}
b2 = {brand: "specialized", year: 2016, color: "blue"}
b3 = {brand: "Releigh", year: 2016, color: "white"}
arr = Bike.create_bikes_array([b1, b2, b3])
# arr = [< Instance of Bike 1>, <Instance of Bike 2>, <Instance of Bike 3>]
# Stretch print: ["scott", "specialized", "Releigh"]
@2-am-zzz
2-am-zzz / javascript_compare.js
Last active December 12, 2016 20:23
Comparing JavaScript and Ruby
// Functions
function hello() {
console.log("Hello World")
}
// Calling a function
hello // function
hello() // "Hello World"
// Returning from functions
@jsmecham
jsmecham / underscore.extensions.js
Created October 17, 2011 15:20
Useful Underscore.js Extensions
(function() {
//
// Iterates over an array of numbers and returns the sum. Example:
//
// _.sum([1, 2, 3]) => 6
//
_.sum = function(obj) {
if (!$.isArray(obj) || obj.length == 0) return 0;
return _.reduce(obj, function(sum, n) {
@suya55
suya55 / ij.sh
Last active June 21, 2017 14:28
Open a project in IntelliJ IDEA from your command line! Raw
#!/bin/sh
# check for where the latest version of IDEA is installed
IDEA=`ls -1d /Applications/IntelliJ\ * | tail -n1`
wd=`pwd`
# Setup your working directory. Edit 'work' to your working directory.
working_dir=`ls -1d ~/work/$1 | head -n1`
# were we given a directory?
if [ -d "$1" ]; then
@hoetmaaiers
hoetmaaiers / handlebars-helpers.md
Last active September 16, 2017 16:25
Handlebars Helpers

Pluralize or singular string based on a number

Handlebars.registerHelper('pluralize', function(number, singular, plural) {
    if (number === 1) {
        return singular;
    } else {
        return (typeof plural === 'string' ? plural : singular + 's');
    }
});
@bmatthewshea
bmatthewshea / ethminer
Last active January 24, 2018 17:18
/etc/default/ethminer service default file
# User settings - Here you can enable/disable a given miner profile:
#
RUNAS="ubuntu" # For the amdgpu-pro driver this user must be a member of 'video' group
DAEMON="/opt/miners/ethminer" # Wherever you installed the binary - make sure its executable by above user.
GPU="-G" # -U (nVidia Cuda) or -G (OpenCL) or -X (mixed Cuda/OpenCL cards)
WORKER="Worker1"
LOGFILE="/var/log/miners/ethminer.log"
# values: pool, proxy, solo
@dkd903
dkd903 / Install_Sublime_Text_3.sh
Last active April 6, 2018 19:10
Install Sublime Text 3 editor on Fedora Linux & Red Hat Linux - 32 Bit Edition. More at: http://digitizor.com/?p=15885
#!/bin/sh
SHORTCUT="[Desktop Entry]
Name=Sublime Text 3
Comment=Edit text files
Exec=/usr/local/sublime-text-3/sublime_text
Icon=/usr/local/sublime-text-3/Icon/128x128/sublime_text.png
Terminal=false
Type=Application
Encoding=UTF-8
Categories=Utility;TextEditor;"
@markselby
markselby / async-gists.js
Last active February 19, 2020 10:26
Load GitHub Gists asynchronously and optionally specify which file to show. This allows you to keep related files in a single gist but show them individually on your pages. The async loading prevents your page rendering from stalling.
function loadGists() {
var els = $('code[gist]'), gists = {}, code = [], stylesheets = [];
// Get elements referencing a gist and build a gists hash referencing the elements that use it
els.each(function(idx, rawEl) {
var el = $(rawEl), gist = el.attr('gist');
rawEl.gist = gist;
rawEl.file = el.attr('file');
gists[gist] = gists[gist] || { targets: [] };
gists[gist].targets.push(el);
});