Skip to content

Instantly share code, notes, and snippets.

@john-doherty
john-doherty / cordova-file-storage.js
Last active August 2, 2023 10:32
An easy way to read/write files in Cordova
var fileStorage = {
/**
* Saves a file on the device
* @param {string} name - filename (can include sub folders)
* @param {string} data - file contents
* @param {boolean} useSandbox - uses protected sandbox if true, otherwise external (default false)
* @returns {Promise} executes .then with saved file path as first param
*/
write: function (name, data, useSandbox) {

Why I hate TypeScript

Warning: These views are highly oppinated and might have some slightly incorrect facts. My experience with typescript was about 2 weeks in Node and a week in angular2.

Not Standard

TypeScript is implementing their own take on JavaScript. Some of the things they are writing will likely never make it in an official ES* spec either.

Technologies that have competing spec / community driven development have a history of failing; take: Flash, SilverLight, CoffeeScript, the list goes on. If you have a large code base, picking TypeScript is something your going to be living with for a long time. I can take a bet in 3 years JavaScript will still be around without a doubt.

Its also worth noting that they have built some things like module system and as soon as the spec came out they ditched it and started using that. Have fun updating!

@gmanau
gmanau / nginx-socketio-ssl-reverse-proxy.conf
Last active March 25, 2024 12:15
How to setup nginx as nodejs/socket.io reverse proxy over SSL
upstream upstream-apache2 {
server 127.0.0.1:8080;
}
upstream upstream-nodejs {
server 127.0.0.1:3000;
}
server {
listen 80;
@Rarst
Rarst / griddle.php
Last active August 24, 2016 20:53
Responsive grid layout backgrounds for Bootstrap.
<?php
if ( isset( $_GET['grid'] ) ) {
add_action( 'wp_print_styles', function () { ?>
<style type="text/css">
@media (min-width: 768px) {
body {
background: url("http://griddle.it/720px-12-30px") repeat-y center top !important;
}
@mbarzeev
mbarzeev / app.js
Last active November 18, 2016 16:20
A Metronome Directive. Taken after Chris Wilson's article (http://www.html5rocks.com/en/tutorials/audio/scheduling/).
// This is the "run" block of your main module
.run(['$window', function (window) {
// First, let's shim the requestAnimationFrame API,
// with a setTimeout fallback
window.requestAnimFrame = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function (callback) {
@aheckmann
aheckmann / storeImgInMongoWithMongoose.js
Created April 17, 2012 19:14
store/display an image in mongodb using mongoose/express
/**
* Module dependencies
*/
var express = require('express');
var fs = require('fs');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
// img path