Skip to content

Instantly share code, notes, and snippets.

View weavermedia's full-sized avatar

Dan Weaver weavermedia

View GitHub Profile
@Killavus
Killavus / ugly_code_refactoring.coffee
Last active March 14, 2022 17:52
Example of possible refactoring of badly written code - loading photos and making it grayed after click
Photos = {}
class Photos.App
constructor: ->
@gui = new Photos.Gui($("#photos-list"))
@backend = new Photos.Backend()
start: =>
@backend.fetchPhotos()
.done(
@kevincennis
kevincennis / buffertowav.js
Last active February 17, 2024 14:05
Buffer to WAV
// assuming a var named `buffer` exists and is an AudioBuffer instance
// start a new worker
// we can't use Recorder directly, since it doesn't support what we're trying to do
var worker = new Worker('recorderWorker.js');
// initialize the new worker
worker.postMessage({
command: 'init',
@tonycoco
tonycoco / controller_spec.rb
Last active May 25, 2023 06:04
The Greatest Hits of Rspec Testing: Volume 1
require "spec_helper"
describe ExampleController do
context "GET #index" do
let(:resources) { FactoryGirl.create_list(:resource) }
before do
get :index
end
@homam
homam / AWS_S3_File_Upload.js
Created January 27, 2014 10:08
How to upload files to AWS S3 with NodeJS SDK
var AWS = require('aws-sdk'),
fs = require('fs');
// For dev purposes only
AWS.config.update({ accessKeyId: '...', secretAccessKey: '...' });
// Read in the file, convert it to base64, store to S3
fs.readFile('del.txt', function (err, data) {
if (err) { throw err; }
@bomberstudios
bomberstudios / sketch-plugins.md
Last active February 26, 2024 07:02
A list of Sketch plugins hosted at GitHub, in no particular order.
@julionc
julionc / 00.howto_install_phantomjs.md
Last active April 26, 2024 09:13
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu

Version: 1.9.8

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
@wetzler
wetzler / gist:6629918
Last active February 23, 2019 21:31
a key with magical powers
d90e5b5598497773de1c57407dd54d65934ba1b5911f6f47311d3c729f510bb5c295284780017a56f17e49234f19c009bfa57f7941413a5dd3c282d7db3692a192b58ea926b637cdcd11377e1e74086641e0672c8b3406aeed49d63ee0a3a3d3751ae7744f08b999df38ca2ccdbb9a2c
@glava
glava / Rakefile
Last active August 8, 2020 12:34
Stop, Start, Restart Rake tasks for Rails
desc 'Stop rails server'
task :stop do
 File.new("tmp/pids/server.pid").tap { |f| Process.kill 9, f.read.to_i }.delete
end
desc 'Starts rails server'
task :start do
Process.exec("rails s puma -d")
end
@p1nox
p1nox / postgresql_configuration_on_ubuntu_for_rails.md
Last active November 29, 2023 04:38
PostgreSQL configuration without password on Ubuntu for Rails

Abstract

You could have postgre installed on localhost with password (or without user or password seted after instalation) but if we are developing we really don't need password, so configuring postgre server without password for all your rails project is usefull.

Install Postgre packages

  • postgresql
  • postgresql-client
  • libpq-dev
@iloveitaly
iloveitaly / .gitattributes
Last active May 8, 2019 19:31
Snippets for Spree Commerce Development
# with my git configuration the spree repo was giving me issues with line endings
# this fixed the issue for me: marking a file as binary causes git to ignore it completely
core/vendor/assets/javascripts/jquery.alerts/jquery.alerts.css.erb binary
core/vendor/assets/javascripts/jquery.alerts/jquery.alerts.js binary
core/vendor/assets/javascripts/jquery.jstree/themes/apple/style.css binary
sample/db/sample/spree/line_items.yml binary
sample/db/sample/spree/products.yml binary