Skip to content

Instantly share code, notes, and snippets.

View nicolasembleton's full-sized avatar
🏠
Working from home

Nicolas Embleton nicolasembleton

🏠
Working from home
View GitHub Profile
@nicolasembleton
nicolasembleton / restart_bluetooth.sh
Last active October 21, 2022 20:10
Restart Bluetooth Daemon on Mac OS X without restarting
#!/bin/bash
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
@nicolasembleton
nicolasembleton / min_max_benchmark.dart
Last active July 28, 2021 12:57
Benchmark of the multiple ways to find min and max in a large List in Dart
import 'dart:math';
import 'package:stats/stats.dart';
class Benchmark {
Benchmark({this.UPPER_BOUND = 100000, this.withSlow = false}) {
reset();
}
int UPPER_BOUND;
bool withSlow;
@nicolasembleton
nicolasembleton / list.log
Created January 16, 2018 22:59
List of most past CryptoCurrency ICO whitepapers PDF (from January 16th 2018), probably incomplete
https://www.gatcoin.io/wp-content/uploads/2017/08/GATCOIN-Whitepaper_ENG-1.pdf
https://appcoins.io/pdf/appcoins_whitepaper.pdf
https://pareto.network/download/Pareto-Technical-White-Paper.pdf
http://betbox.ai/BetBoxBizWhitepaper.pdf
https://www.aidcoin.co/assets/documents/whitepaper.pdf
https://irp-cdn.multiscreensite.com/ee070c4a/files/uploaded/Whitepaper%20AlchemyByte%20%26%20SLHashByte%20v1.6.pdf
http://goldminecoin.io/wp-content/uploads/2017/11/GoldMineCoin_ENG.pdf
https://www.pecun.io/wp-content/uploads/2017/10/Pecunio_White_Paper_011.pdf
http://ico.cryptoibet.com/assets1/pdf/whitepaper-1.pdf
https://www.bitnettoken.org/documents/BNETWhitePaper.pdf
@nicolasembleton
nicolasembleton / customer.io_upload.js
Created November 20, 2012 11:29
Import your customer data with custom parameters into customer.io
//#!/usr/bin/env node
var http = require("http"),
fs = require("fs"),
sys = require('sys'),
exec = require('child_process').exec;
var ENDPOINT="https://app.customer.io/api/v1/customers/";
var SITEID="YOUR SITE ID";
var APIKEY="YOUR API KEY";
- (UIViewController *)topViewController{
return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}
- (UIViewController *)topViewController:(UIViewController *)rootViewController
{
if (rootViewController.presentedViewController == nil) {
return rootViewController;
}

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

var dict = require('dictionary');
var solveJumble = function (string) {
'use strict';
var originalBag = string.split('');
var anagrams = [];
var findAnagrams = function (bag, word) {
var tempBag, tempWord;
for (var i = 0; i < bag.length; i++) {
tempBag = bag.slice();
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
set :application, "appname"
set :deploy_to, "/var/www"
set :scm, :git
set :repository, "git@github.com:user/app.git"
default_run_options[:pty] = true
set :user, "www-data"
set :domain, "foo.tld"
set :normalize_asset_timestamps, false