Skip to content

Instantly share code, notes, and snippets.

View Linell's full-sized avatar
🧙

Linell Bonnette Linell

🧙
View GitHub Profile
" Language Specific scratch buffers with date
" ---------------------------------------------------------------------------------
function! s:DScratch(scratch_ft)
let scratch_dir = '~/Dropbox/scratch/buffers'
let scratch_date = strftime('%Y%m%d')
let scratch_file = 'scratch-'. scratch_date . '.' . a:scratch_ft
let scratch_buf = bufnr(scratch_file)
if scratch_buf == -1
exe 'split ' . scratch_dir . '/' . scratch_file
@dteoh
dteoh / custom_ar_relation_relay_connection.rb
Last active October 28, 2019 16:51
GrapQL Ruby: Custom Relay connection class for ActiveRecord::Relation objects
# This custom relay connection class exists because the built-in connection
# class is broken when max_page_size is used.
#
# See: https://github.com/rmosolgo/graphql-ruby/issues/1109
class CustomArRelationRelayConnection < GraphQL::Relay::BaseConnection
def cursor_from_node(item)
cursor_col = item.class.implicit_order_column
encode(item.send(cursor_col).to_s)
end
@phillip-haydon
phillip-haydon / jsonb_merge.sql
Created December 6, 2016 10:17
Deep Merge two jsonb documents in PostgreSQL
CREATE OR REPLACE FUNCTION jsonb_merge(left JSONB, right JSONB) RETURNS JSONB AS $$
var mergeJSON = function (target, add) {
function isObject(obj) {
if (typeof obj == "object") {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
return true; // search for first object prop
}
}
@jeffweiss
jeffweiss / basic_bench.exs
Last active August 29, 2015 14:20
Numbers to words
defmodule BasicBench do
use Benchfella
@num :random.uniform(999_999_999_999)
bench "interpolation" do
@num
|> NumToWordsString.say
end
@markusklems
markusklems / lambda-dynamo
Last active September 24, 2021 03:48
Short aws lambda sample program that puts an item into dynamodb
// create an IAM Lambda role with access to dynamodb
// Launch Lambda in the same region as your dynamodb region
// (here: us-east-1)
// dynamodb table with hash key = user and range key = datetime
console.log('Loading event');
var AWS = require('aws-sdk');
var dynamodb = new AWS.DynamoDB({apiVersion: '2012-08-10'});
exports.handler = function(event, context) {
@mattbailey
mattbailey / macvim_dphase.rb
Last active August 29, 2015 13:56
homebrew formula for dphase's fork of macvim
require 'formula'
# Reference: https://github.com/b4winckler/macvim/wiki/building
# my install command: brew install macvim_dphase --env-std --override-system-vim --custom-icons --HEAD
class MacvimDphase < Formula
head 'https://github.com/dphase/macvim.git', :branch => 'master'
option "custom-icons", "Try to generate custom document icons"
option "override-system-vim", "Override system vim"
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active November 15, 2024 09:51
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: