Skip to content

Instantly share code, notes, and snippets.

@Razoxane
Razoxane / reverse_anti-join.sql
Last active July 29, 2016 05:00
Preferred way to suppress reversed journal entries
SELECT je.*
FROM journal_entry AS je ON a.assetID = je.assetID
AND je.reference IN ('OPEN','AQ','DR')
AND CASE WHEN je.reference = 'DR' THEN je.description LIKE 'Direct Reinvestment%' ELSE 1=1 END
AND je.entryType = 'debit'
AND IFNULL(je.assetID,0) > 0
/* some join conditions for the je table, can vary depending on what's being joined (account or asset) */
LEFT JOIN journal_entry AS aj ON je.fundID = aj.fundID
AND je.memberAccountID = aj.memberAccountID
@Razoxane
Razoxane / 0_reuse_code.js
Last active August 29, 2015 14:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@Razoxane
Razoxane / banker_round.js
Created February 24, 2016 00:49 — forked from FrankFang/banker_round.js
Gaussian/Banker's Rounding in JavaScript
function evenRound(num, decimalPlaces) {
var d = decimalPlaces || 0;
var m = Math.pow(10, d);
var n = +(d ? num * m : num).toFixed(8); // Avoid rounding errors
var i = Math.floor(n), f = n - i;
var e = 1e-8; // Allow for rounding errors in f
var r = (f > 0.5 - e && f < 0.5 + e) ?
((i % 2 == 0) ? i : i + 1) : Math.round(n);
return d ? r / m : r;
}
@Razoxane
Razoxane / Default (OSX).sublime-keymap -- User
Last active May 13, 2016 00:34 — forked from coldnebo/Default (OSX).sublime-keymap -- User
Jade's custom keymaps for Sublime Text 2
[
/* Fixes Home/End keys for OSX */
{ "keys": ["home"], "command": "move_to", "args": {"to": "bol" } },
{ "keys": ["end"], "command": "move_to", "args": {"to": "eol" } },
{ "keys": ["shift+home"], "command": "move_to", "args": {"to": "bol", "extend": true } },
{ "keys": ["shift+end"], "command": "move_to", "args": {"to": "eol", "extend": true } },
{ "keys": ["super+home"], "command": "move_to", "args": {"to": "bof" } },
{ "keys": ["super+end"], "command": "move_to", "args": {"to": "eof" } },
{ "keys": ["super+shift+home"], "command": "move_to", "args": {"to": "bof", "extend": true } },
{ "keys": ["super+shift+end"], "command": "move_to", "args": {"to": "eof", "extend": true } },
@Razoxane
Razoxane / git-backup-to-AWS-S3.sh
Created June 3, 2016 02:11 — forked from philippb/git-backup-to-AWS-S3.sh
Complete git repository backup script to AWS S3
#!/bin/bash
# Script to backup git repo to S3
# Set bucket, dir, password and account to use for the backup. I keep mine in local env vars
# These are set by localrc which lives on an encrypted home directory and is executed by my bashrc
bucket=$GITHUB_BACKUP_BUCKET
dir=$GITHUB_BACKUP_DIR
password=$GITHUB_BACKUP_PASSWORD
account=$GITHUB_ACCOUNT
@Razoxane
Razoxane / .gitconfig
Created August 15, 2016 10:47 — forked from pksunkara/config
Sample of git config file (Example .gitconfig)
[user]
name = Pavan Kumar Sunkara
email = [email protected]
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
[sendemail]
smtpencryption = tls
smtpserver = smtp.gmail.com
@Razoxane
Razoxane / gitgrereplace.sh
Last active October 19, 2016 23:47
Git Grep Replace
git grep -lz 'AAA' | xargs -0 perl -i'' -pE "s/AAA/BBB/g"
@Razoxane
Razoxane / .gitconfig
Last active March 14, 2017 07:12
Git Config - Jade
[core]
editor = nano
[interactive]
singleKey = true
[push]
default = simple
[color]
ui = true
[alias]
#### Generic ####
@Razoxane
Razoxane / reloadCSS.js
Created July 28, 2017 23:48 — forked from kdzwinel/reloadCSS.js
Reload CSS files without reloading the page
function reloadCSS() {
const links = document.getElementsByTagName('link');
Array.from(links)
.filter(link => link.rel.toLowerCase() === 'stylesheet' && link.href)
.forEach(link => {
const url = new URL(link.href, location.href);
url.searchParams.set('forceReload', Date.now());
link.href = url.href;
});
@Razoxane
Razoxane / laravel_conditional_index_migration.php
Created August 8, 2017 01:35
Laravel - Create Index If Not Exists / Drop Index If Exists
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class LaravelConditionalIndexMigration extends Migration
{
/**
* Run the migrations.