Skip to content

Instantly share code, notes, and snippets.

View dgmike's full-sized avatar

Michael dgmike

View GitHub Profile
@dgmike
dgmike / scrollTo.js
Last active September 16, 2019 11:05 — forked from Eworm/gist:5866977
Scroll function cause zepto doesn't have scrolltop animation
// Scroll function cause zepto doesn't have scrolltop animation
;function scrollNew(scrollTo, time) {
var scrollFrom = parseInt(document.body.scrollTop),
i = 0,
runEvery = 5, // run every 5ms
time = time || 1000,
interval
;
scrollTo = parseInt(scrollTo);
// early experiments with node had mysterious double requests
// turned out these were for the stoopid favicon
// here's how to short-circuit those requests
// and stop seeing 404 errors in your client console
var http = require('http');
http.createServer(function (q, r) {
// control for favicon
<?php
if (!function_exists('http_build_url'))
{
define('HTTP_URL_REPLACE', 1); // Replace every part of the first URL when there's one of the second URL
define('HTTP_URL_JOIN_PATH', 2); // Join relative paths
define('HTTP_URL_JOIN_QUERY', 4); // Join query strings
define('HTTP_URL_STRIP_USER', 8); // Strip any user authentication information
define('HTTP_URL_STRIP_PASS', 16); // Strip any password authentication information
define('HTTP_URL_STRIP_AUTH', 32); // Strip any authentication information
define('HTTP_URL_STRIP_PORT', 64); // Strip explicit port numbers
@dgmike
dgmike / password_hashing_api.md
Created October 2, 2012 13:11
The new Secure Password Hashing API in PHP 5.5

The new Secure Password Hashing API in PHP 5.5

The [RFC for a new simple to use password hashing API][rfc] has just been accepted for PHP 5.5. As the RFC itself is rather technical and most of the sample codes are something you should not use, I want to give a very quick overview of the new API:

Why do we need a new API?

Everybody knows that you should be hashing their passwords using bcrypt, but still a surprising number of developers uses insecure md5 or sha1 hashes (just look at the recent password leaks). One of the reasons for this is that the crypt() API is ridiculously hard to use and very prone to programming mistakes.

@dgmike
dgmike / redmine_svn_to_git_migrator.rb
Created October 2, 2012 02:39 — forked from rca/redmine_svn_to_git_migrator.rb
Redmine SVN to Git Migrator
#!/usr/bin/ruby
#
# Migration Tool for Redmine issue and time entry comments from SVN revisions to Git (i.e. r1234 => commit:abcdef789)
# ==============================
# (c) 2009 Christoph Olszowka & Sebastian Georgi, Capita Unternehmensberatung
#
# We used this when we migrated two of our main repositories from svn to git (see http://gist.github.com/139478)
# and wanted to have our revision links in Redmine reflect that change, too.
#
@dgmike
dgmike / gist:3815866
Created October 2, 2012 02:39 — forked from zuckercode/gist:3714230
redmine installer
# add database 'redmine' and user 'redmine' to mysql
aptitude -y install ruby libruby libopenssl-ruby libpgsql-ruby rubygems apache2 libapache2-mod-passenger
aptitude -y install subversion
aptitude -y install install libmysql-ruby libmysqlclient-dev
aptitude install libpq-dev libsqlite3-dev libmagick9-dev graphicsmagick-libmagick-dev-compat
cd /var/www
svn co http://redmine.rubyforge.org/svn/branches/2.0-stable redmine
cd redmine
cp config/database.yml.example config/database.yml
vim config/database.yml
@dgmike
dgmike / gist:3815778
Created October 2, 2012 02:12 — forked from mannieschumpert/gist:3815767
WordPress Taxonomy Snippet for Sublime Text
<snippet>
<content><![CDATA[
// Create taxonomy
add_action( 'init', 'create_${1:FUNCTION}' );
function create_${1:FUNCTION}() {
$labels = array(
'name' => _x( '${3:PLURAL}', 'taxonomy general name' ),
'singular_name' => _x( '${2:SINGULAR}', 'taxonomy singular name' ),
'search_items' => __( 'Search ${3:PLURAL}' ),
@dgmike
dgmike / redmine_installation.sh
Created October 2, 2012 01:58 — forked from gaza3g/redmine_installation.sh
Redmine Installation Steps
Steps to take when installing redmine
- Download XCode and then go to => Preferences => Install CommandLine Tools (or download the cmd line tools without instaling XCode from apple site)
- sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2 #fixes error when bundler tries to install json
- Install homebrew
- brew install mysql
@dgmike
dgmike / gist:3814312
Created October 1, 2012 20:49 — forked from kalebrozo/gist:3814281
Install Magento 1.7.0.2 With Sample Data By SSH
mkdir demo
cd demo
wget http://www.magentocommerce.com/downloads/assets/1.7.0.2/magento-1.7.0.2.tar.gz
wget http://www.magentocommerce.com/downloads/assets/1.6.1.0/magento-sample-data-1.6.1.0.tar.gz
tar -zxvf magento-1.7.0.2.tar.gz
tar -zxvf magento-sample-data-1.6.1.0.tar.gz
mv magento-sample-data-1.6.1.0/media/* magento/media/
mv magento-sample-data-1.6.1.0/magento_sample_data_for_1.6.1.0.sql magento/data.sql
mv magento/* magento/.htaccess .
chmod o+w var var/.htaccess app/etc
@dgmike
dgmike / css-stats-ack.sh
Created October 1, 2012 20:48 — forked from kwaledesign/css-stats-ack.sh
shell script to generate some css file statistics
#!/bin/bash
## v1.0.6
## this script will gernerate css stats
### example output
# CSS STATS
# ----------
# Floats: 132