Skip to content

Instantly share code, notes, and snippets.

@amogower
amogower / app.js
Last active February 17, 2016 20:36
Multer File Upload - you need to npm install and save multer and s3 (Amazon s3) - app.js is the front-end app.js, not the api app.js
function submitForm(){
event.preventDefault();
var $form = $(this)
var method = $form.attr('method');
var url = "http://localhost:3000" + $form.attr('action');
var isFileUpload = $form.attr("enctype") === 'multipart/form-data';
var data = $form.serialize();
if(isFileUpload) {
data = new FormData($form[0]);
@amogower
amogower / app.py
Last active January 31, 2016 15:22
Python auto-tweet ISP script
#!/usr/bin/python
import os
import sys
import csv
import datetime
import time
import twitter
def test():
@amogower
amogower / Gmail Confirmation Email Search Link
Created February 19, 2016 09:11
Linking directly to the confirmation email sent to the user speeds up the email confirmation process.
@amogower
amogower / Sticky Side Bar
Created February 19, 2016 17:30
Sticky side bar JS
var $sidebar = $('#sidebar'),
$window = $(window),
offset = $sidebar.offset(),
topPadding = 0;
$window.scroll(function() {
if ($window.scrollTop() > offset.top)
{
$('#sidebar').removeClass('checkout-sidebar');
$('#sidebar').addClass('checkout-sidebar-fixed');
@amogower
amogower / form_check.js
Created March 9, 2016 12:40
Check form for changes and only get the difference
function getFormOriginalState()
{
startItems = convertSerializedArrayToHash($form.serializeArray());
}
function checkFormForChanges()
{
var currentItems = convertSerializedArrayToHash($form.serializeArray());
var dataToSubmit = hashDiff(startItems, currentItems);
return dataToSubmit;

Keybase proof

I hereby claim:

  • I am amogower on github.
  • I am amogower (https://keybase.io/amogower) on keybase.
  • I have a public key ASAz8a5KXBNJEHEgcJfadd5IpQCxUTv9s7iG8Er5HQBboQo

To claim this, I am signing this object:

# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@amogower
amogower / dispatcher.js
Created January 12, 2017 19:13
Redux Concepts (thanks @narendrashetty)
const action = {
type, // specify the action type
data // optional data can be passed
};
Store.prototype.dispatch = function(action) {
// based on the action type
// generate a new state of the application,
// by passing it to a reducer
const state = this.reducer(action);
@amogower
amogower / test.js
Created January 15, 2017 19:05
Javascript Test for iOS and Firefox
var iOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
var ff = navigator.userAgent.indexOf('Firefox') > 0;
@amogower
amogower / event_delegation.js
Created January 25, 2017 22:30
Event Delegation for Efficiency
document.addEventListener('DOMContentLoaded', function() {
let body = document.querySelector('.body');
// attach event listener to whole body
body.addEventListener('click', function(e) {
if (e.target) {
switch (e.target.nodeName) {
case 'DIV':
console.log('You clicked on a div');