Skip to content

Instantly share code, notes, and snippets.

View smoll's full-sized avatar

Shujon Mollah smoll

View GitHub Profile
@smoll
smoll / add_up_single_column_in_tsv.rb
Last active August 29, 2015 14:04
Using Ruby and smarter_csv gem to process Statement Exports (Tab-separated values file with headers)
require 'benchmark'
require 'smarter_csv'
require 'bigdecimal' # using BigDecimal instead of Float
require 'bigdecimal/util'
# modify these variables
filename = "new_statement_detail_Yorck_Eysel_10942_Q12014.txt" # put the real path to your .txt file here
rows_per_chunk = 10000 # processes this many rows in each "chunk"
name_of_column = "Label Share Net Receipts"
number_format = "EU" # set this to "EU" or "US"
@smoll
smoll / gist:292a352839a2f503f588
Created September 15, 2014 16:29
hello world form from html in a URL
# Enter this into URL:
data:text/html,<h1 id="welcome">Hello, World!</h1><form>Name: <input type="text" id="name" required><br>Notes: <input type="text" id="notes"><input type="submit" id="submit_form"></form>
# Modified:
data:text/html,<h1 id="welcome">Hello, World!</h1><form>Name: <input type="text" id="name" required><br>Notes: <input type="text" id="notes"><input type="submit" id="new_submit"></form>
@smoll
smoll / rerun.rb
Created September 29, 2014 15:19
Modify cucumber v1.3.17 rerun formatter to only rerun failed scenarios
require 'cucumber/formatter/io'
module Cucumber
module Formatter
# The formatter used for <tt>--format rerun</tt>
#
# This formatter keeps track of all failing features and print out their location.
# Example:
#
# features/foo.feature:34 features/bar.feature:11:76:81
#!/bin/bash
# Functions ==============================================
# return 1 if global command line program installed, else 0
# example
# echo "node: $(program_is_installed node)"
function program_is_installed {
# set to 1 initially
local return_=1
@smoll
smoll / unparse.rb
Last active November 5, 2015 18:39
Adapted from the unparser usage example, at https://github.com/mbj/unparser#usage
require 'parser/current'
require 'unparser'
require 'byebug'
module YourHelper
def s(type, *children)
Parser::AST::Node.new(type, children)
end
end
@smoll
smoll / gist:7f552ff0eb12a7c362f321b9f56aad65
Created June 14, 2016 13:33 — forked from bruchu/gist:8230184
change s3 content-type using aws ruby sdk
bash:
export AWS_ACCESS_KEY_ID='...'
export AWS_SECRET_ACCESS_KEY='...'
export AWS_REGION='us-east-1'
irb or ruby script:
require 'aws-sdk'
s3 = AWS::S3.new
@smoll
smoll / Auth Class
Created January 6, 2017 20:05 — forked from singledigit/Auth Class
Pattern for using Cognito User Pools as authentication against Cognito Identity
import {inject} from 'aurelia-framework';
import {Session} from './session';
@inject(Session)
export class Auth {
// App specific
userPoolId = 'us-east-1_fgCWraBkF';
appClientId = '57lq262n28o7ddt8i36jcjj7qd';
@smoll
smoll / post-npm-install.js
Last active February 16, 2018 21:53
Quick 'n Dirty hack to rewrite minify.js to make join-monster play nice with React Native
const fs = require('fs')
const path = require('path')
const rewriteFile = (file, value, replacement) => {
const data = fs.readFileSync(file, 'utf-8')
const replaced = data.replace(value, replacement)
fs.writeFileSync(file, replaced, 'utf-8')
}
const rewriteMinifyJs = () => {
@smoll
smoll / keybase.md
Created March 16, 2018 20:03
keybase.md

Keybase proof

I hereby claim:

  • I am smoll on github.
  • I am smoll (https://keybase.io/smoll) on keybase.
  • I have a public key ASBHo8T9zVPaZkuH45iYFk59KEMa8-hPmrmgw4mGOxGuPgo

To claim this, I am signing this object:

@smoll
smoll / Pipfile
Created January 8, 2019 16:33
Testing gsutil's transparent compression of a csv file (and reading it back from the python lib)
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
google-cloud-storage = "*"