Skip to content

Instantly share code, notes, and snippets.

View waptik's full-sized avatar
💻
Learning JavaScript and ReactJS...

TheVirginBrokey waptik

💻
Learning JavaScript and ReactJS...
View GitHub Profile
@mathewbyrne
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@steve-jansen
steve-jansen / Startup.Cmd.cmd
Created March 8, 2013 17:22
A Command Prompt auto-run script to injet DOSKEY macros into the shell from a text file, change the initial working directory to a SUBST'd drive letter, update the PATH to include SysInternal utilities, and log all Command Prompt launches to a history file
:: Name: Startup.Cmd.cmd
:: Purpose: Initializes a Windows command prompt shell
:: Author: stevejansen_github@mac.com
:: Revision: April 2012
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
:: self-install this script, but, don't force an overwrite if an auto run script is already configured
IF /I "%~1"=="/install" (
@gabrieljmj
gabrieljmj / Converter.class.php
Last active November 22, 2017 12:07
Currency converter using Google API You must have the curl extension in PHP active.
<?php
/**
* @author @GabrielJMJ /twitter
* @description Abstract class to define a interface of a converter
* @link https://gist.github.com/GabrielJMJ/6977968 Gist on GitHub
**/
abstract class Converter{
protected $valueWithCurrency;
protected $toCurrency;
@nabucosound
nabucosound / heroku_env_copy.sh
Created December 30, 2013 12:40
Script to copy environment variables from an existing heroku app to another one
#!/bin/bash
# Source: http://blog.nonuby.com/blog/2012/07/05/copying-env-vars-from-one-heroku-app-to-another/
set -e
sourceApp="$1"
targetApp="$2"
while read key value; do
@hkasera
hkasera / mongo-struc.js
Created March 6, 2014 10:12
A script for mongo shell to get the collection structure.
var conn = new Mongo();
db = conn.getDB(<DB_NAME>);
var cursor = db.<COLLECTION>.find();
var items = [];
items = cursor.toArray();
var dbstruc = {};
for (var i = 0; i < items.length; ++i) {
var target = items[i];
getKP(target,dbstruc);
}
@egel
egel / auto-remove-sublime-license-popup
Last active April 8, 2024 23:00
Auto-remove Sublime's license popup
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sublime_plugin
import subprocess
from time import sleep
import sys
cl = lambda line: subprocess.Popen(line, shell=True, stdout=subprocess.PIPE).communicate()[0].strip()
log = lambda message: sys.stderr.write("Log: %s\n" % message)
@vladikoff
vladikoff / doskey.md
Last active July 9, 2024 10:53
Setup Persistent Aliases & Macros in Windows Command Prompt (cmd.exe) using DOSKey

Setup Persistent Aliases & Macros in Windows Command Prompt (cmd.exe) using DOSKey

Saved from Archive.org, Date: May 14, 2010 Author: Jesse Webb

http://web.archive.org/web/20140330024520/http://devblog.point2.com/2010/05/14/setup-persistent-aliases-macros-in-windows-command-prompt-cmd-exe-using-doskey/

Our development machines here at Point2 are not standardized; we have a mixture of Windows XP, 7, and Mac OSX/Unix computers. I find myself constantly switching back and forth between command prompt interfaces when pair programming. As a result, I catch myself using “ls” to list a directories contents regardless of what system I am on. I am currently using a Windows XP machine for my developer box and I wanted to setup an alias to the “ls” command to actually perform a “dir”. Here is how I accomplished it…

There is a command available in a Window’s shell that let’s you “alias” command to whatever you please: DOSKey. It allows you to create “macros” to execute one or more other commands with a custom nam

@zxbodya
zxbodya / render-react-with-rxjs.md
Last active November 1, 2021 08:49
React with RxJS, reactive way :)

Observable React elements with RxJS

Note: if you want to skip history behind this, and just looking for final result see: rx-react-container

When I just started using RxJS with React, I was subscribing to observables in componentDidMount and disposing subscriptions at componentWillUnmount.

But, soon I realised that it is not fun to do all that subscriptions(that are just updating property in component state) manually, and written mixin for this...

Later I have rewritten it as "high order component" and added possibility to pass also obsarvers that will receive events from component.

@TheSkorm
TheSkorm / gist:cb9171e92d0db850363f
Last active October 7, 2021 13:55
ec2 download torrent
#!/bin/bash
#don't actually use this - it's silly
#sns needs to be setup
#ec2 role must have access to read tags, write to s3 and publish to sns
#start isntance with
#aws ec2 run-instances --image-id ami-fd9cecc7 --count 1 --instance-type t2.micro --key-name deb --security-group-ids sg-c948cbac --subnet-id subnet-ff9b3a9a --user-data "`base64 ~/download.sh`" --instance-initiated-shutdown-behavior terminate --associate-public-ip-address --iam-profile pirate
#set the download url with once you have the instanceid
#aws ec2 create-tags --resources i-54388388 --tags Key=URL,Value="http://cdimage.debian.org/debian-cd/8.0.0/amd64/bt-cd/debian-8.0.0-amd64-netinst.iso.torrent"
@Yimiprod
Yimiprod / difference.js
Last active July 13, 2024 15:07
Deep diff between two object, using lodash
/**
* This code is licensed under the terms of the MIT license
*
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {