Skip to content

Instantly share code, notes, and snippets.

View r3wt's full-sized avatar
😅
Move Fast. Break Things.

Garrett R. Morris r3wt

😅
Move Fast. Break Things.
  • Walmart
  • Hartman, Arkansas, United States
View GitHub Profile
<?php
/* Usage Example
$save_handler = new MyRedisSessionModule();
$save_handler->save_path = "tcp://127.0.0.1:6379?weight=1";
session_set_save_handler($save_handler, true);
*/
class MyRedisSessionModule implements SessionHandlerInterface {
/**
@Albert-IV
Albert-IV / gist:5483a81917ea37ef381b
Created May 5, 2014 21:02
Example VersionError Fix
function saveRecord(record, args, cb) {
record.save(function(e) {
if (e && e.message == "VersionError: No matching document found.") {
recordModel.findById(record._id, function(e, newRecord) {
if(e) return cb(e);
reSaveRecord(record, newRecord, cb);
});
}
@aligoren
aligoren / lt_install.sh
Last active August 18, 2018 10:26
Light Table Installation Script
#!/bin/bash
#title :lt_install.sh
#description :LightTable Installation Script
#author :<goren.ali@yandex.com> Ali GOREN
#date :2015-10-31
#version :0.1
#usage :chmod u+x, ./lt_install.sh
#notes :progressFilt Source-> http://stackoverflow.com/a/4687912
#bash_version :4.3.11(1)-release
@padcom
padcom / jquery.post-json.js
Created January 3, 2012 21:54
A shorthand method to posting JSON data using jQuery
(function($) {
$.postJSON = function(url, data, success, dataType) {
if (typeof data != 'string') {
data = JSON.stringify(data);
}
$.ajax({
url : url,
type: "post",
data: data,
dataType: dataType || "json",
@thetutlage
thetutlage / scroll.js
Created December 13, 2016 17:21
Scroll to the bottom of an element with smooth animation - Pure Javascript
function scrollTo (element, duration) {
if (!element) {
return
}
var target = element.scrollHeight
target = Math.round(target)
duration = Math.round(duration)
if (duration < 0) {
return false
}
@mrcoles
mrcoles / AsyncStripeProvider.js
Last active December 8, 2020 14:28
A react provider abstraction for loading the stripe.js file asynchronously to use with Stripe Elements
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { StripeProvider } from 'react-stripe-elements';
export default class AsyncStripeProvider extends Component {
static propTypes = {
apiKey: PropTypes.string.isRequired
};
// constructor
@Integralist
Integralist / flatten-array.js
Created May 20, 2015 08:35
Array flatten function written in ES6 syntax
const flattenTco = ([first, ...rest], accumulator) =>
(first === undefined)
? accumulator
: (Array.isArray(first))
? flattenTco([...first, ...rest])
: flattenTco(rest, accumulator.concat(first))
const flatten = (n) => flattenTco(n, []);
console.log(flatten([[1,[2,[[3]]]],4,[5,[[[6]]]]]))
@katowulf
katowulf / app.js
Last active February 24, 2022 06:51
Simple paginate example in AngularFire with Firebase.util (http://firebase.github.io/firebase-util/)
var app = angular.module('app', ['firebase']);
app.controller('ctrl', function($scope, $pageArray) {
$scope.pageItems = $pageArray(ref, 'number');
});
app.factory('$pageArray', function($firebaseArray) {
return function(ref, field) {
// create a Paginate reference
var pageRef = new Firebase.util.Paginate(ref, field, {maxCacheSize: 250});
@paulmelnikow
paulmelnikow / shadows.scss
Last active August 22, 2022 15:35
Sass Mixin: Google Material Design Shadow
/**
* A mixin which helps you to add depth to elements according to the Google Material Design spec:
* http://www.google.com/design/spec/layout/layout-principles.html#layout-principles-dimensionality
*
* Please note that the values given in the specification cannot be used as is. To create the same visual experience
* the blur parameter has to be doubled.
*
* Adapted from a LESS version at https://medium.com/@Florian/freebie-google-material-design-shadow-helper-2a0501295a2d
*
* Original Author: Florian Kutschera (@gefangenimnetz), Conceptboard GmbH (@conceptboardapp)
@arfon
arfon / big_query_examples.md
Last active September 19, 2022 13:00
BigQuery Examples for blog post

How many times shouldn't it happen...

-- https://news.ycombinator.com/item?id=11396045

SELECT count(*)
FROM (SELECT id, repo_name, path
        FROM [bigquery-public-data:github_repos.sample_files]
 ) AS F