Skip to content

Instantly share code, notes, and snippets.

@esfand
esfand / utf8.c
Created August 14, 2019 22:08 — forked from stanislaw/utf8.c
Some C functions to work with UTF-8 string : you can check if a string is valid UTF-8, get the length of a UTF-8 string and replace things in a UTF-8 string. All `char *` arguments must be regular, null-byte terminated, C strings. I've tried to optimize the best I could. I'd be grateful for any suggestions or improvements. Please note I have onl…
//
// utf8.c
// training
//
// Created by Conrad Kleinespel on 5/27/13.
// Copyright (c) 2013 Conrad Kleinespel. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
@esfand
esfand / javascript-promise-timeout.js
Last active July 18, 2018 16:03 — forked from john-doherty/javascript-promise-timeout.js
Adds a timeout to a JavaScript promise, rejects if not resolved within timeout period
/**
* Wraps a promise in a timeout, allowing the promise to reject
* if not resolved within a specified period of time.
* @param {integer} ms - milliseconds to wait before rejecting
* promise if not resolved
* @param {Promise} promise to monitor
* @Example
* promiseTimeout(1000, fetch('https://courseof.life/johndoherty.json'))
* .then(function(cvData){
* alert(cvData);
@esfand
esfand / background.js
Last active July 12, 2018 15:33 — forked from chrahunt/background.js
Chrome extension for testing chrome.storage.local.
(function(window, document, undefined) {
var Storage = {};
window.Storage = Storage;
Storage.tracking = true;
Storage.track = function() {
Storage.tracking = !Storage.tracking;
if (Storage.tracking) {
console.log("Tracking storage performance.");
@esfand
esfand / hovercard.go
Created July 10, 2018 22:30 — forked from linxlunx/hovercard.go
Twitter User Hovercard Endpoint
package main
import (
"fmt"
"log"
"io/ioutil"
"net/http"
"encoding/json"
"regexp"
"strings"
var secondes = Math.floor((Math.random() * 10) + 3);
var duration = secondes;
$('#activity-popup-dialog-body').find('.not-following').find('button.follow-button').each(function() {
var _this = this;
setTimeout(function() {
$(_this).trigger('click');
}, duration * 1000);
duration += secondes;
@esfand
esfand / twitter.css
Created July 4, 2018 08:24 — forked from chloechantelle/twitter.css
Twitter CSS
@-moz-document domain("twitter.com")
{
/* custom options */
:root
{
--bg1: #1d1e2a !important;
--bg2: #14151F !important;
--text1: #aaa !important;
@esfand
esfand / _webfaction_setup.rst
Created June 16, 2018 20:57 — forked from k4ml/_webfaction_setup.rst
setting up a stack on webfaction

Setting up Webfaction for modern Python deployment

last updated: 4/5/2011

note that this stuff is always a moving target, much of this has been cribbed and combined from various blog posts. Much of the information was out of date from those, and if it is more than a couple months after the last updated date above, consider some of this likely to now be out of date.

@esfand
esfand / nginx-0765-installer.txt
Created June 16, 2018 07:41 — forked from robflaherty/nginx-0765-installer.txt
Nginx 0.7.65 installer for Webfaction
-----BEGIN WEBFACTION INSTALL SCRIPT-----
#!/bin/env python2.4
"""
Nginx 0.7.65 Installer New
"autostart": not applicable
"extra info": Enter domain name for the nginx app
"""
@esfand
esfand / build_nginx_from_source.sh
Created June 15, 2018 23:00 — forked from a-luna/build_nginx_from_source.sh
Shell Script: Build NGINX from Source with Third Party Modules (Cache Purge, GeoIP2), Completely Non-Interactive, No User Input Required
#!/bin/bash -e
# build_nginx_from_source.sh
# Author: Aaron Luna
# Website: alunablog.com
#
# This script downloads the source code for the latest version of NGINX
# (libraries required to build various NGINX modules are also downloaded)
# and builds NGINX according to the options specified in the ./configure
# command. Many of the possible configuration options are explained at
# the link below:
@esfand
esfand / ubuntu-php7-install.bash
Created May 29, 2018 16:41
Ubuntu 14.04 PHP7 (Install from Source)
#!/usr/bin/env bash
sudo -i;
apt-get update;
apt-get install --yes \
git \
bison \
autoconf \