Skip to content

Instantly share code, notes, and snippets.

@aheinze
aheinze / gist:02db57da725cf7ba4047
Last active October 30, 2022 07:30
letterAvatar - create Letter avatar based on name initials
/*
* LetterAvatar
*
* Create Letter avatar based on Initials -
* based on https://gist.github.com/leecrossley/6027780
*/
(function(w, d){
function LetterAvatar (name, size) {
http://compose.mail.yahoo.com/?to={email_address}&subject={title}&body={url}
http://digg.com/submit?url={url}
http://pinterest.com/pin/create/link/?url={url}
http://service.weibo.com/share/share.php?url={url}&appkey=&title={title}&pic=&ralateUid=
http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url={url}
http://surfingbird.ru/share?url={url}&description={text}&screenshot={image}&title={title}
http://vk.com/share.php?url={url}&title={title}&comment={text}
http://widget.renren.com/dialog/share?resourceUrl={url}&srcUrl={url}&title={title}&description={text}
http://www.addthis.com/bookmark.php?url={url}
http://www.douban.com/recommend/?url={url}&title={title}
@aheinze
aheinze / fuzzy-search.php
Last active August 20, 2018 07:44
Fuzzy Search function - returning score
<?php
function fuzzy_search($search, $text, $distance = 3){
$needles = explode(' ', mb_strtolower($search, 'UTF-8'));
$tokens = explode(' ', mb_strtolower($text, 'UTF-8'));
$score = 0;
$levenshtein_utf8 = function ($s1, $s2) {
$map = [];
@aheinze
aheinze / gist:263225e99ca18e2dc2f636d49e7f6357
Last active July 13, 2016 07:45
Get css variable (cross browser)
/**
<style>
.var-test:before {
content: 'hello';
}
</style>
@aheinze
aheinze / password_hash (PHP)
Created August 21, 2013 12:39
A Compatibility library with PHP 5.5's simplified password hashing API.
<?php
/**
* A Compatibility library with PHP 5.5's simplified password hashing API.
*
* @author Anthony Ferrara <ircmaxell@php.net>
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @copyright 2012 The Authors
*/
if (!defined('PASSWORD_DEFAULT')) {
var TemplateEngine = function(html, options) {
var re = /<%([^%>]+)?%>/g,
reExp = /(^( )?(if|for|else|switch|case|break|{|}))(.*)?/g,
code = 'var r=[];\n',
cursor = 0,
add = function(line, js) {
js? (code += line.match(reExp) ? line + '\n' : 'r.push(' + line + ');\n') :
(code += line != '' ? 'r.push("' + line.replace(/"/g, '\\"') + '");\n' : '');
return add;
};
@aheinze
aheinze / execute.js
Last active February 25, 2016 16:05
Execute async function
/**
asyncexec(function(times){
for (var x=0, y;x<times;x++) {
y = x/2;
}
release(x);
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs"),
port = process.argv[2] || 3000,
mimeTypes = {
'asc' : 'text/plain',
'au' : 'audio/basic',
'avi' : 'video/x-msvideo',

##Given Apache 2 and MySQL are already installed.

#Update MacPorts sudo port selfupdate;sudo port -u upgrade outdated

#Install PHP 5.4.* sudo port install php54 php54-apache2handler ##Activate Apache Module cd /opt/local/apache2/modules

@aheinze
aheinze / gist:5704831
Last active December 18, 2015 01:38
chown -R www-data:www-data /var/www
chown -R www-data:www-data /var/www
chown -R www-data:www-data /usr/share/nginx/html