Skip to content

Instantly share code, notes, and snippets.

@ahmadawais
ahmadawais / VSCode_Node_Babel_Recipe.md
Last active November 1, 2022 11:31
VSCode Node + Babel Recipe | Solves: vscode debug unexpected token import

VSCode Node + Babel Recipe

Debug Modern JavaScript with VSCode. Part of VSCode Course.

1. init a module:

npm init -y
@pamelafox
pamelafox / hosts
Created July 23, 2018 15:04
etc/hosts for news blocking
### News Aggregators
127.0.0.1 redditate.com
127.0.0.1 news.google.com
127.0.0.1 news.yahoo.com
127.0.0.1 news.ycombinator.com
### News
127.0.0.1 cnn.com
127.0.0.1 recode.net
127.0.0.1 techcrunch.com
127.0.0.1 mashable.com
@bellbind
bellbind / spiral.html
Created August 15, 2014 06:31
[javascript][threejs] sphere spiral
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r68/three.min.js"
></script>
<script src="https://rawgit.com/mrdoob/three.js/master/examples/js/controls/Trac
kballControls.js"
></script>
<script src="spiral.js"></script>
@tomdale
tomdale / local-storage-array.js
Created April 28, 2014 02:12
Ember Array that writes every change to localStorage
export default Ember.ArrayProxy.extend({
localStorageKey: null,
init: function() {
var localStorageKey = this.get('localStorageKey');
if (!localStorageKey) {
throw new Error("You must specify which property name should be used to save " + this + " in localStorage by setting its localStorageKey property.");
}
@cyrildiagne
cyrildiagne / addon_crawler.coffee
Created April 17, 2014 07:47
OpenFrameworks addons finder (NodeJS)
config = require '../config'
config.setEnvironment 'development'
fs = require 'fs'
path = require 'path'
colors = require 'colors'
github = require 'octonode'
client = github.client
id : config.GITHUB_CLIENT_ID
@johnnyman727
johnnyman727 / intel-hex-parser.js
Last active August 29, 2015 13:57
JavaScript Intel Hex Parser For BlueGiga BLE Device Updates
var fs = require('fs');
function parseIntelHexData(path, callback) {
var hex = fs.readFileSync(path).toString();
console.log('loaded file');
// Split the file into lines
var hexLines = hex.split('\n');
// The last line is an empty string
hexLines.pop();
@aras-p
aras-p / preprocessor_fun.h
Last active May 28, 2024 05:15
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
<!--
This code is a working example of the code shown in the 12devs[0]'s article:
"Rapid Prototyping with AngularJS"[1] by Tom Ashworth[2].
I put it here for reference ;-)
[0] http://12devs.co.uk
[1] http://12devs.co.uk/articles/rapid-prototyping-with-angularjs/
[2] http://twitter.com/phuunet
@tedmiston
tedmiston / nodejs-tcp-example.js
Last active May 20, 2024 11:27
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
@gnomeontherun
gnomeontherun / angularjs-interceptor.js
Last active November 4, 2020 06:46
Intercept XHR/Ajax requests with AngularJS http interceptors. This allows you to globally intercept and modify requests and responses. You don't need to declare all of the methods, just the ones you need. Some example uses would be logging errors, adding extra headers, or triggering 'loading' screens. This intercepts ALL requests/responses, so y…
// Intercepting HTTP calls with AngularJS.
angular.module('MyApp', [])
.config(function ($provide, $httpProvider) {
// Intercept http calls.
$provide.factory('MyHttpInterceptor', function ($q) {
return {
// On request success
request: function (config) {
// console.log(config); // Contains the data about the request before it is sent.