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
@marijn
marijn / README.markdown
Last active October 1, 2023 13:42
List of countries in YAML, CSV and TXT format
@bradwright
bradwright / websockets-server.js
Created June 11, 2011 23:29
Pure Node.js WebSockets server
/*
* node-ws - pure Javascript WebSockets server
* Copyright Bradley Wright <brad@intranation.com>
*/
// Use strict compilation rules - we're not animals
'use strict';
var net = require('net'),
crypto = require('crypto');
@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",
@mshafrir
mshafrir / states_hash.json
Created May 9, 2012 17:05
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@cou929
cou929 / detect-private-browsing.js
Last active April 6, 2024 03:21
Detect private browsing mode (InPrivate Browsing or Incognito).
function retry(isDone, next) {
var current_trial = 0, max_retry = 50, interval = 10, is_timeout = false;
var id = window.setInterval(
function() {
if (isDone()) {
window.clearInterval(id);
next(is_timeout);
}
if (current_trial++ > max_retry) {
window.clearInterval(id);
@umidjons
umidjons / files-array-normalize.md
Created March 31, 2014 14:35
Normalize $_FILES array when uploading multiple files (from php.net)

Normalize $_FILES array when uploading multiple files

When uploading multiple files, the $_FILES variable is created in the form:

Array
(
    [name] => Array
        (
            [0] => foo.txt
<?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);
});
}
@mscdex
mscdex / test.js
Last active September 15, 2023 11:55
sharing sessions between node.js and php using redis
var express = require('express'),
app = express(),
cookieParser = require('cookie-parser'),
session = require('express-session'),
RedisStore = require('connect-redis')(session);
app.use(express.static(__dirname + '/public'));
app.use(function(req, res, next) {
if (~req.url.indexOf('favicon'))
return res.send(404);
@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)