Skip to content

Instantly share code, notes, and snippets.

@joefiorini
joefiorini / idiomatic_mofo.rb
Created Jan 7, 2012
Camelize Hash keys to return in JSON request. In other words, idiomatic JSON for your Rubies. Consider this pseudo-code as it's about 40% untested.
View idiomatic_mofo.rb
def HashExtensions(hash)
hash.extend(HashExtensions)
end
module HashExtensions
def camelize_keys
dup.camelize_keys!
end
View csrf.js
$.ajaxPrefilter(function(options, originalOptions, jqXHR) {
var token;
if (!options.crossDomain) {
token = $('meta[name="csrf-token"]').attr('content');
if (token) {
return jqXHR.setRequestHeader('X-CSRF-Token', token);
}
}
});
View sway-launcher-desktop.sh
#!/usr/bin/env bash
# terminal application launcher for sway, using fzf
# Based on: https://gitlab.com/FlyingWombat/my-scripts/blob/master/sway-launcher
# https://gist.github.com/Biont/40ef59652acf3673520c7a03c9f22d2a
shopt -s nullglob
if [[ "$1" == 'describe' ]]; then
shift
if [[ $2 == 'command' ]]; then
title=$1
@joefiorini
joefiorini / init.vim
Created Sep 3, 2019
My 2019 NeoVim Config
View init.vim
" == VIM PLUG ================================
call plug#begin('~/.vim/plugged')
"------------------------ COC ------------------------
" coc for tslinting, auto complete and prettier
Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'}
" coc extensions
let g:coc_global_extensions = ['coc-eslint', 'coc-tsserver', 'coc-emmet', 'coc-css', 'coc-html', 'coc-json', 'coc-yank', 'coc-prettier', 'coc-import-cost', 'coc-svg', 'coc-gitignore', 'coc-lists', 'coc-snippets', 'coc-git', 'coc-pairs', 'coc-marketplace', 'coc-stylelint', 'coc-jest', 'coc-project', 'coc-vimlsp']
"------------------------ VIM TSX ------------------------
@joefiorini
joefiorini / Brocfile.js
Created Jun 12, 2014
My setup for building an Angular.js app with Broccoli & grunt
View Brocfile.js
var ngMin = require('broccoli-ng-min');
var uglify = require('broccoli-uglify-js');
var compileSass = require('broccoli-ruby-sass');
var pickFiles = require('broccoli-static-compiler');
var mergeTrees = require('broccoli-merge-trees');
var findBowerTrees = require('broccoli-bower');
var env = require('broccoli-env').getEnv();
var compileES6 = require('broccoli-es6-concatenator');
var app = 'app/scripts';
View Main.elm
module Main exposing (..)
import Html exposing (Html, program, text)
import MountableProgram as Mountable exposing (Mountable, mountableProgram)
import Time
type alias Model =
()
@joefiorini
joefiorini / rails.nix
Created Sep 18, 2014
Nix Expression for Running Rails Apps
View rails.nix
with (import <nixpkgs> {});
stdenv.mkDerivation {
name = "717-app";
buildInputs = [ libiconv openssl ruby21 postgresql git nodejs ];
src = "/src/717";
builder = builtins.toFile "builder.sh" ''
set -e
source $stdenv/setup
View Main.elm
module Main exposing (..)
type alias Point =
( Int, Int )
printNums =
let
( x1, y1 ) =
View utils.re
type bn;
type bigNumber;
type hex =
| Hex(string);
type address =
| Address(string);
View Main.hs
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
import Network.Ethereum.Web3
import Network.Ethereum.Web3.TH
import System.Environment (getEnv)
import Control.Monad.IO.Class (liftIO)
import Data.Text (unpack)
import Data.String (fromString)