Skip to content

Instantly share code, notes, and snippets.

View AdamBrodzinski's full-sized avatar

Adam Brodzinski AdamBrodzinski

View GitHub Profile
@AdamBrodzinski
AdamBrodzinski / gist:4010249
Created November 4, 2012 04:32
JavaScript replaceAt string method
// allows you to replace a strings char at a specific index
String.prototype.replaceAt=function(index, char) {return this.substr(0, index) + char + this.substr(index+char.length);}
@AdamBrodzinski
AdamBrodzinski / meteor-1.2.1-install
Created April 8, 2016 06:08
Install a stable version of Meteor CLI
#!/bin/sh
# This is the Meteor install script!
#
# Are you looking at this in your web browser, and would like to install Meteor?
#
# MAC AND LINUX:
# Just open up your terminal and type:
#
# curl https://install.meteor.com/ | sh
@AdamBrodzinski
AdamBrodzinski / rethinkdb_helpers.ex
Created February 26, 2016 17:17 — forked from sikanhe/rethinkdb_helpers.ex
helpers for rethinkdb elixir
defmodule RethinkDB.Helpers do
def run(query) do
query
|> do_run
|> handle_response
end
def handle_response(%RethinkDB.Exception.ConnectionClosed{}) do
raise "Cannot connect to RethinkDB"
defmodule MyApp.RethinkDB.Helpers do
def run(query, opts) do
query
|> MyApp.Database.run(opts)
|> handle_response
end
def run(query) do
run(query, [])
@AdamBrodzinski
AdamBrodzinski / karma.config.js
Last active February 21, 2016 18:00
Karma React Setup (drop these in /tests/karma/ )
module.exports = function(config) {
config.set({
basePath: '../../',
frameworks: ['jasmine', 'jquery-2.1.0'],
plugins: [
'karma-babel-preprocessor',
'karma-jquery',
'karma-jasmine',
'karma-mocha-reporter',
],
defmodule App.Helpers do
use Timex
import App.Rethink, only: [run: 1]
alias RethinkDB.Query
def get(table, id) when is_bitstring(id) do
Query.table(table)
|> Query.get(id)
@AdamBrodzinski
AdamBrodzinski / rethink_query_wrapper.ex
Created February 1, 2016 00:42 — forked from sikanhe/rethink_query_wrapper.ex
Functions to wrap commonly used rehinkdb queries with error handling
defmodule App.Query do
import App.Database, only: [run: 1]
alias RethinkDB.Query
def get(table, id) when is_bitstring(id) do
Query.table(table)
|> Query.get(id)
|> run
|> catch_errors
|> handle_get_response
@AdamBrodzinski
AdamBrodzinski / gist:8562723
Created January 22, 2014 17:08
Vanilla Bling
var $ = document.querySelectorAll.bind(document);
Element.prototype.on = Element.prototype.addEventListener;
$('#somelink')[0].on('touchstart', handleTouch);
IronRouter.prototype.mapResource = function(resource){
var router = this;
var _routes = [
{ name: resource, path: '/' + resource, action: 'index' },
{ name: 'show' + resource, path: '/' + resource + '/:id', action: 'show' }
];
_.each(_routes, function(route, index){
router.map(function(){
this.route(route.name, {
@AdamBrodzinski
AdamBrodzinski / setup.sh
Last active December 29, 2015 00:42
Ubuntu Setup Script for DO
#!/usr/bin/env bash
apt-get update
apt-get upgrade
sudo apt-get install autossh
# prevent bruteforce on SSH
apt-get install fail2ban
# setup firewall