Skip to content

Instantly share code, notes, and snippets.

View halfnibble's full-sized avatar
🎃
Coding

Josh Wedekind halfnibble

🎃
Coding
View GitHub Profile
import React, { useEffect, useRef, useState, useCallback } from 'react';
type IframeGoogleDocsProps = {
url: string,
};
export function IframeGoogleDoc({ url }: IframeGoogleDocsProps) {
const [iframeTimeoutId, setIframeTimeoutId] = useState<any>();
const iframeRef: any = useRef(null);
@harlow
harlow / cache.go
Created August 24, 2016 18:23
Golang cache map
package cache
import (
"crypto/sha256"
"encoding/json"
"fmt"
"os"
"sync"
"time"
)
///////////////////////////
// ES6 original
////////////////////////////
class A extends B {
constructor(x) {
this.x = x;
}
b() {return this.x};
}
@jridgewell
jridgewell / Box.js
Last active February 4, 2018 23:13
Backbone + Incremental DOM
var Box = Backbone.Model.extend({
defaults: {
top: 0,
left: 0,
color: 0,
content: 0
},
initialize: function() {
@daftspunk
daftspunk / ConvertTwoSpacesToFour.sublime-macro
Created October 30, 2014 00:00
Convert 2 spaces to 4 spaces, Sublime Text macro
//
// Converts code indentation from 2 spaces to 4 spaces
//
// For a hotkey, add to Preferences > Key Bindings - User:
//
// { "keys": ["ctrl+alt+i"], "command": "run_macro_file", "args": {"file": "res://Packages/User/ConvertTwoSpacesToFour.sublime-macro"} }
//
[
@neara
neara / forms.py
Last active June 10, 2024 15:30
Django Class Based Views and Inline Formset Example
from django.forms import ModelForm
from django.forms.models import inlineformset_factory
from models import Sponsor, Sponsorship
class SponsorForm(ModelForm):
class Meta:
model = Sponsor
@sap1ens
sap1ens / backbone-custom-method.js
Created February 1, 2013 16:35
Adding Backbone.js custom REST method
var MyModel = Backbone.Model.extend({
someMethod: function(opts) {
var url = this.url() + '/someMethod',
// note that these are just $.ajax() options
options = {
url: url,
type: 'POST'
};
// add any additional options, e.g. a "success" callback or data
@ruudud
ruudud / gist:1922646
Created February 27, 2012 09:08
Underscore templates with Django syntax
// Ovveride Underscore.js' template format
_.templateSettings = {
evaluate: /\{%([\s\S]+?)%\}/g,
interpolate: /\{\{(.+?)\}\}/g
};