Skip to content

Instantly share code, notes, and snippets.

@fiveisprime
fiveisprime / default.js
Created December 19, 2013 15:18
Express router.
var express = require('express')
, routes = require('./server/routes')
, path = require('path')
, app = express();
app.set('port', process.env.PORT || 3000);
app.set('view engine', 'hbs');
app.set('views', path.resolve(__dirname, 'views'));
app.disable('x-powered-by');
@fiveisprime
fiveisprime / app.js
Last active January 3, 2016 05:59
Cloud storage.
var express = require('express')
, formidable = require('formidable')
, fs = require('fs')
, path = require('path')
, app = express()
, storedFiles = [];
//
// Serve the cloud storage contents.
//
@eculver
eculver / recursive remove .AppleDouble directories
Created May 26, 2011 00:03
recursive remove .AppleDouble directories
find . -name \.AppleDouble -exec rm -rf {} \;
@fiveisprime
fiveisprime / transform.js
Last active November 29, 2017 10:40
Replace `_id` with string `id` and remove `__v` when calling `toObject()` in Mongoose.
if (!MySchema.options.toObject) {
PlanSchema.options.toObject = {};
}
MySchema.options.toObject.transform = function(doc, ret) {
// Set the id from the retrun object value which will be a string.
ret.id = ret._id;
delete ret._id;
delete ret.__v;
@pyricau
pyricau / JellyBeanSpanFixTextView.java
Last active October 8, 2021 07:16
A TextView to prevent a bug with spans on JellyBean: http://code.google.com/p/android/issues/detail?id=35466
// Copyright 2012 Pierre-Yves Ricau
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
@linakis
linakis / generate-ios-screenshots.sh
Created April 15, 2016 11:50
Imagemagick bash script to generate portrait iOS app store screenshots from 6+ input
#!/bin/sh
# Generate iPhone Portrait Screenshots from 6+ for app store submission.
# From folder containing 6+ screenshots do:
# ./generate-ios-screenshots.sh *.png
mkdir -p 3.5
mkdir -p 4.0
mkdir -p 4.7
mkdir -p 5.5
@keyboardr
keyboardr / HeadlessFragment.java
Last active December 31, 2021 01:05
A file template for creating a headless Fragment. The attach() methods add the fragment to the parent if it doesn't already exist and returns the attached fragment. The methods ensure that the parent implements the parent interface. If needed, parameters may be added to the attach() methods to supply fragment arguments.
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
#parse("File Header.java")
public class ${NAME} extends Fragment {
private static final String FRAG_TAG = ${NAME}.class.getCanonicalName();
@dandjelkovic
dandjelkovic / AFError.errorCodes.txt
Last active January 20, 2023 05:01
AlamoFire AFError error codes and their enum case. Helpful for mapping e.g. Crashlytics Issues.
AFError.errorCode 0:
createUploadableFailed(error: Error)
AFError.errorCode 1:
createURLRequestFailed(error: Error)
AFError.errorCode 2:
downloadedFileMoveFailed(error: Error, source: URL, destination: URL)
AFError.errorCode 3:
@romannurik
romannurik / CheatSheet.java
Last active May 16, 2023 13:42
Android helper class for showing cheat sheets (tooltips) for icon-only UI elements on long-press. This is already default platform behavior for icon-only action bar items and tabs. This class provides this behavior for any other such UI element.
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@mluisbrown
mluisbrown / Rx2Ras-Cheatsheet.md
Last active December 3, 2023 17:28
An RxSwift to ReactiveSwift cheatsheet