Skip to content

Instantly share code, notes, and snippets.

type TemplateType = {
template: string;
id: string;
};
function withTemplate(templateObj: TemplateType) {
return function (constructor: any) {
let el = document.getElementById(templateObj.id);
let p = new constructor();
if (el) {
@tlimpanont
tlimpanont / filtering_sorting_field_selection_paging.txt
Last active March 10, 2021 09:43
RESTful best practices Query String Params
<?php
/*
Based on http://blog.mwaysolutions.com/2014/06/05/10-best-practices-for-better-restful-api/
7. Provide filtering, sorting, field selection and paging for collections
*/
/******
@nsantos16
nsantos16 / react-query-demo.js
Created May 15, 2020 17:52
React query API demo
// An individual movie
useQuery(['movies', 5], ...);
// A list of movies that are "released"
useQuery(['movies', { type: 'released' }], ...);
@itang
itang / pg.go
Created December 23, 2013 02:22
golang + postgreSQL example
package main
import (
"database/sql"
"fmt"
"log"
// load postgres driver
_ "github.com/lib/pq"
)
@daotoad
daotoad / init.vim
Created August 20, 2019 01:07
Vim Settings
" Set this variable to 1 to fix files when you save them.
let g:ale_fix_on_save = 1
highlight ALEWarning ctermbg=DarkMagenta
highlight ALEError ctermbg=DarkBlue
" Enable completion where available.
" This setting must be set before ALE is loaded.
let g:ale_completion_enabled = 1
let g:ale_fixers = {
@tilfin
tilfin / createHTMLNotification.js
Last active April 7, 2022 03:25
It is to easily pass data to notification html at createHTMLNotification for Chrome Extension. The way is to store data as JSON string in location.hash.
var data = { image: "image.jpg", text: "text..." };
var popup = webkitNotifications.createHTMLNotification(
'notification.html#' + encodeURIComponent(JSON.stringify(data)) );
@al-the-x
al-the-x / .tmuxrc
Created May 10, 2011 20:11 — forked from xentek/.tmux.conf
custom .tmux.conf (renamed to .tmuxrc) file for your multiplexing pleasure
###
# Custom tmux configuration cobbled together from google and trial & error
# by Eric Marden (xentek.net), heavily modified by David Rogers (@al-the-x).
##
# set the command prefix to match gnuscreen (i.e. CTRL+a)
set-option -g prefix C-a
# use the NEW prefix key to "send-prefix" instead of the default
unbind-key C-b; bind-key C-a send-prefix
// Built with IMPACT - impactjs.org
(function (window) {
"use strict";
Number.prototype.map = function (istart, istop, ostart, ostop) {
return ostart + (ostop - ostart) * ((this - istart) / (istop - istart));
};
Number.prototype.limit = function (min, max) {
return Math.min(max, Math.max(min, this));
};
Number.prototype.round = function (precision) {
@Apsu
Apsu / vimrc
Created April 25, 2021 15:40
Colemak DHm vim remap
noremap f e
noremap p r
noremap b t
noremap j y
noremap l u
noremap u i
noremap y o
noremap ' p
noremap r s
noremap s d
@ahmedelgabri
ahmedelgabri / Sublime Text command log
Created September 21, 2013 19:19
Log Sublime Text command in the console, very helpful when trying to figure out command you want to create shortcuts for.
sublime.log_commands(True)