Skip to content

Instantly share code, notes, and snippets.

View IAMtheIAM's full-sized avatar

IAMtheIAM

  • Central Arizona, USA
View GitHub Profile
@smsohan
smsohan / rename_angular_parts
Last active April 28, 2016 15:55
AngularJS renaming exercise
Because I think the hardest part of getting started with AngularJS is it's esoteric names, I'm suggesting the following replacements of the AngularJS terminology.
scope -> state
factory -> data/models
filter -> helper
directive {restrict: 'E'} -> custom_tag
directive {restrict: 'A'} -> custom_attribute
@IAMtheIAM
IAMtheIAM / javascript_loader.js
Last active January 12, 2017 18:10 — forked from hagenburger/javascript_loader.js
Dynamically load JavaScript files with callback when finished
// Example:
function myCallback() {
// cool stuff here
}
// don't invoke the function here with () i.e. myCallback(), just reference the name of it it - myCallback.
JavaScript.load("/javascripts/something.js", myCallback);
// With callback (that’s the good thing):
@markerikson
markerikson / dispatching-action-creators.js
Last active May 2, 2020 14:27
Dispatching action creators comparison
// approach 1: define action object in the component
this.props.dispatch({
type : "EDIT_ITEM_ATTRIBUTES",
payload : {
item : {itemID, itemType},
newAttributes : newValue,
}
});
// approach 2: use an action creator function
@soheilhy
soheilhy / mochatutorial.md
Last active March 18, 2022 05:23
Mocha Tutorial

Testing Node.JS applications using Mocha

Mocha is a unittest framework for Node. In this document, we explain how you can test your javascript code and also your HTTP servers.

Installing Mocha

Use npm to install Mocha:

npm install mocha
@dweldon
dweldon / install-docker.sh
Last active April 8, 2022 11:18
Install docker CE on Linux Mint 18.3
#!/usr/bin/env bash
# https://docs.docker.com/install/linux/docker-ce/ubuntu/
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable"
sudo apt-get update
sudo apt-get install docker-ce
# https://docs.docker.com/compose/install/
@MoOx
MoOx / package.json.js
Last active June 26, 2022 22:18
Boost your Webpack performance with DLLPlugin (will bundle as dll all your "dependencies", see comment in package.json)
{
"private": true,
// ...
"#dependencies": "dependencies are the one shipped to the client",
"dependencies": {
"babel-polyfill": "^6.7.4",
"react": "^15.0.0",
// ...
"whatwg-fetch": "^0.11.1"
},
@burkeholland
burkeholland / FileReader.md
Last active September 30, 2022 08:12
Reading A Local JSON File With NativeScript

In NativeScript, the http module doesn't currently support making network requests to the local file system. That work is intended to be done by the file reader. It's pretty simple to read a local file and parse its contents as JSON.

This is the TypeScript/Promise version of what Emil Oberg created for the same question on StackOverflow. This module should be reusable for any and all asyncronous local JSON read operations.

import * as fs from 'file-system';

var documents = fs.knownFolders.currentApp();

class FileReader {
@MFry
MFry / Webpack and toastr
Last active February 16, 2023 16:58
Getting toastr npm to play with webpack
//In case anyone was having the same issue in getting toastr to run with webpack and es6
@mathisonian
mathisonian / index.md
Last active March 22, 2023 05:31
requiring npm modules in the browser console

demo gif

The final result: require() any module on npm in your browser console with browserify

This article is written to explain how the above gif works in the chrome (and other) browser consoles. A quick disclaimer: this whole thing is a huge hack, it shouldn't be used for anything seriously, and there are probably much better ways of accomplishing the same.

Update: There are much better ways of accomplishing the same, and the script has been updated to use a much simpler method pulling directly from browserify-cdn. See this thread for details: mathisonian/requirify#5

inspiration

@mandiwise
mandiwise / Stop tracking directory in Git repo
Last active April 11, 2023 16:28
A command to stop tracking and entire directory in a Git repo
// Reference: http://stackoverflow.com/questions/936249/stop-tracking-and-ignore-changes-to-a-file-in-git
$ git rm --cached -r <dir>