Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active April 23, 2024 08:01
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@wilon
wilon / vim-surround使用指南.MD
Last active April 18, 2024 01:40
vim-surround使用指南,vim-surround如何使用

普通模式

命令 说明 + 示例
ds 删除括号
ds " "Hello world!" =>
Hello world!
cs 替换括号
cs "( "Hello world!" =>
(Hello world!)
cS 替换括号,括号内文本做新一行
cS "{ "Hello world!" => {     Hello world! }
@taion
taion / server.js
Last active March 11, 2024 10:20
GraphQL subscription server with Socket.IO, backed by Redis Pub/Sub
const redisClient = redis.createClient(REDIS_URL);
const listeners = Object.create(null);
function addListener(channel, listener) {
if (!listeners[channel]) {
listeners[channel] = [];
redisClient.subscribe(channel);
}
listeners[channel].push(listener);
@vaultah
vaultah / PEP366_boilerplate.py
Last active September 5, 2023 21:28
Generic boilerplate code for setting __package__ attribute for relative imports
import sys, importlib
from pathlib import Path
def import_parents(level=1):
global __package__
file = Path(__file__).resolve()
parent, top = file.parent, file.parents[level]
sys.path.append(str(top))
@JoeKarlsson
JoeKarlsson / 1README.md
Last active January 1, 2023 19:33
graphql + dataloader + express-graphql Live Coding Demo

How to test if Dataloader is working correctly, we are going to turn on server logging in order to see how many queries are being made to our db. If Dataloader is setup correctly, we should only see one hit on our db perrequest, even if duplicate data is being requested. Here's how to enable logging on postgresql. Note - This is the Mac way to enable logging.

  • subl /usr/local/var/postgres/postgresql.conf

  • around line 434 log_statement = 'all' uncomment and set to all log_statement = 'all'

  • then brew service restart postgresql

@zchee
zchee / actionlist.vim
Last active April 19, 2024 13:22
IdeaVim actionlist
--- Actions ---
$Copy <M-C>
$Cut <M-X> <S-Del>
$Delete <Del> <BS> <M-BS>
$LRU
$Paste <M-V>
$Redo <M-S-Z> <A-S-BS>
$SearchWeb <A-S-G>
$SelectAll <M-A>
$Undo <M-Z>
@aodin
aodin / gist:9493190
Last active March 23, 2024 20:24
Parsing JSON in a request body with Go
package main
import (
"encoding/json"
"io/ioutil"
"log"
"net/http"
)
type Message struct {
@markgoodyear
markgoodyear / 01-gulpfile.js
Last active May 5, 2023 03:21
Comparison between gulp and Grunt. See http://markgoodyear.com/2014/01/getting-started-with-gulp/ for a write-up.
/*!
* gulp
* $ npm install gulp-ruby-sass gulp-autoprefixer gulp-cssnano gulp-jshint gulp-concat gulp-uglify gulp-imagemin gulp-notify gulp-rename gulp-livereload gulp-cache del --save-dev
*/
// Load plugins
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
cssnano = require('gulp-cssnano'),
@obstschale
obstschale / octave.md
Last active March 29, 2024 22:51
An Octave introduction cheat sheet.
@joaoneto
joaoneto / login.test.js
Created March 13, 2013 13:49
Login session test with mocha
var request = require('supertest'),
should = require('should'),
app = require('../server');
var Cookies;
describe('Functional Test <Sessions>:', function () {
it('should create user session for valid user', function (done) {
request(app)
.post('/v1/sessions')