Skip to content

Instantly share code, notes, and snippets.

View cblair's full-sized avatar

Colby Blair cblair

View GitHub Profile
@kraihn
kraihn / .gitconfig
Created June 15, 2017 13:24
WebStorm as Git mergetool
[merge]
tool = webstorm
[mergetool "webstorm"]
cmd = cmd.exe //c "\"FULL_PATH_TO-->/webstorm.bat" merge \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\"\"
trustExitCode = true
[diff]
tool = webstorm
[difftool "webstorm"]
cmd = cmd.exe //c "\"FULL_PATH_TO-->/webstorm.bat" diff \"$LOCAL\" \"$REMOTE\"\"
@zcaceres
zcaceres / Include-in-Sequelize.md
Last active July 13, 2024 13:46
using Include in sequelize

'Include' in Sequelize: The One Confusing Query That You Should Memorize

When querying your database in Sequelize, you'll often want data associated with a particular model which isn't in the model's table directly. This data is usually typically associated through join tables (e.g. a 'hasMany' or 'belongsToMany' association), or a foreign key (e.g. a 'hasOne' or 'belongsTo' association).

When you query, you'll receive just the rows you've looked for. With eager loading, you'll also get any associated data. For some reason, I can never remember the proper way to do eager loading when writing my Sequelize queries. I've seen others struggle with the same thing.

Eager loading is confusing because the 'include' that is uses has unfamiliar fields is set in an array rather than just an object.

So let's go through the one query that's worth memorizing to handle your eager loading.

The Basic Query

@sbose78
sbose78 / update-version-package.sh
Last active April 11, 2024 19:36
Pre-commit hook to update package.json
#!/bin/bash
set -e
update_version(){
if [[ "$DONT_BUMP_VERSION" -ne "1" ]]
then
echo " Bumping version.. "
else
echo "Version will not be bumped since variable DONT_BUMP_VERSION is set."
exit 0
@revskill10
revskill10 / lopmonhoc.js.jsx
Created January 22, 2014 09:25
Integrate Datatable with React.js
/** @jsx React.DOM */
var LopMonHoc = React.createClass({
getInitialState: function(){
return {data: []}
},
loadData: function(){
$.ajax({
url: '/daotao/lops',
success: function(data){
@aras-p
aras-p / hg and git snippets and stats.md
Last active September 28, 2021 10:02
hg churn and log cheat sheet, ono graphql

Git

Fetch single branch (trunk): git fetch origin trunk:trunk (add -u flag when already on that branch)

Make a new worktree (similar to hg share): git worktree add --no-checkout --detach ../mynewfolder

Converting Hg repo to Git:

; get https://github.com/frej/fast-export somewhere
// Usage:
// Put this in a separate file and load it as the first module
// (See https://github.com/jrburke/requirejs/wiki/Internal-API:-onResourceLoad)
// Methods available after page load:
// rtree.map()
// - Fills out every module's map property under rtree.tree.
// - Print out rtree.tree in the console to see their map property.
// rtree.toUml()
// - Prints out a UML string that can be used to generate UML
// - UML Website: http://yuml.me/diagram/scruffy/class/draw