Skip to content

Instantly share code, notes, and snippets.

View levbrie's full-sized avatar

Lev Brie levbrie

  • River
  • New York, NY
View GitHub Profile
@bvaughn
bvaughn / react-lifecycle-cheatsheet.md
Last active March 2, 2023 13:29
React lifecycle cheatsheet

React lifecycle cheatsheet

Method Side effects1 State updates2 Example uses
Mounting
componentWillMount Constructor equivalent for createClass
render Create and return element(s)
componentDidMount DOM manipulations, network requests, etc.
Updating
componentWillReceiveProps Update state based on changed props

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.

@timprepscius
timprepscius / export_messages.py
Created July 7, 2016 19:14 — forked from hastyeagle/export_messages.py
Export iOS/iMessage chat logs to HTML or text
#!/usr/bin/env python
import sys, getopt
import urllib
import urlparse
import base64
import mimetypes
import cgi
import sqlite3
import os
@rootscity
rootscity / gist:fcf909f5820407a67c8e
Created February 7, 2016 05:24
angular-material modal drag directive
// Usage
//
//<md-dialog rc-drag="md-toolbar" ng-cloak>
// <form>
// <md-toolbar>
// ...
// </md-toolbar>
// <md-dialog-content>
// ...
// </md-dialog-content>
@Chandler
Chandler / slack_history.py
Last active March 26, 2024 14:35
Download Slack Channel/PrivateChannel/DirectMessage History
print("UPDATE AUG 2023: this script is beyond old and broken")
print("You may find interesting and more up to date resources in the comments of the gist")
exit()
from slacker import Slacker
import json
import argparse
import os
# This script finds all channels, private channels and direct messages
import random
import time
import numpy
from exceptions import ValueError
class PushID(object):
# Modeled after base64 web-safe chars, but ordered by ASCII.
PUSH_CHARS = ('-0123456789'
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
@mikelehen
mikelehen / generate-pushid.js
Created February 11, 2015 17:34
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
@ericelliott
ericelliott / essential-javascript-links.md
Last active March 28, 2024 23:01
Essential JavaScript Links
@grandchild
grandchild / selfspy.conf
Last active August 29, 2015 14:07
An example config for selfspy
# Example selfspy.conf. Put this in your ~/.config/ to use it
# with the systemd .service file.
# Note: You cannot indent lines in here!
# Defaults, used by both selfspy and selfstats.
[Defaults]
# Don't use quotes around the password, they'd be part of it!
# Example:
@jrthib
jrthib / AnotherController.js
Created July 16, 2014 23:50
Factory using promises to start the socket.io authentication and session after logging into an Angular app.
(function() {
'use strict';
function AnotherController($scope, socket) {
// use the socket factory through your app, but you must use socket.then
// so that the actions occur once the socket is established
socket.then(function(socket) {
socket.emit('some_socket_event', {});
});