Skip to content

Instantly share code, notes, and snippets.

View hightemp's full-sized avatar
🎯
Focusing

Anton Panov hightemp

🎯
Focusing
View GitHub Profile
@hightemp
hightemp / gist:2387916
Created April 14, 2012 21:16 — forked from borriglione/gist:2237588
Magento Snippets

Magento Snippets

Download extension manually using pear/mage

Pear for 1.4, mage for 1.5. File downloaded into /downloader/.cache/community/

./pear download magento-community/Shipping_Agent
./mage download community Shipping_Agent

Clear cache/reindex

@hightemp
hightemp / jquery.extend.js
Created May 24, 2012 12:26 — forked from tanepiper/jquery.extend.js
jQuery extend for NodeJS / Object & Array Deep Copy for NodeJS
/*
jQuery.extend extracted from the jQuery source & optimised for NodeJS
Twitter: @FGRibreau / fgribreau.com
Usage:
var Extend = require('./Extend');
// Extend
var obj = Extend({opt1:true, opt2:true}, {opt1:false});
@hightemp
hightemp / http_authentication
Created November 11, 2012 18:42 — forked from ipoval/http_authentication
Http basic authentication for padrino
module HttpAuthentication
module Basic
def authenticate_or_request_with_http_basic(realm = 'Application')
authenticate_with_http_basic || request_http_basic_authentication(realm)
end
def authenticate_with_http_basic
if auth_str = request.env['HTTP_AUTHORIZATION']
return 'login:password' == ActiveSupport::Base64.decode64(auth_str.sub(/^Basic\s+/, ''))
end
These are some notes from troubleshooting common OpenStack Errors that I have run into in the past year. These were mostly from Diablo and Essex but some are applicable to future releases especially surrounding Nova.
/*Check all services
$nova-manage service list (check for XXX or smiley face)
Binary Host Zone Status State Updated_At
nova-scheduler openstack1 nova enabled : – ) 2012-05-12 22:42:14
nova-compute openstack1 nova enabled : – ) 2012-05-12 22:42:12
nova-network openstack1 nova enabled : – ) 2012-05-12 22:42:14
OS=`echo \`uname\` | tr '[:upper:]' '[:lower:]'`
AURL="https://gist.githubusercontent.com/hightemp/5071909/raw/"
ANAME=".bash_aliases"
TMPAPATH="/tmp/$ANAME"
HOMEAPATH="~/$ANAME"
[ "$OS" = "windowsnt" ] && OS_WIN="yes"
[ "$OS" = "darwin" ] && OS_MAC="yes"
[ "$OS" = "linux" ] && OS_LIN="yes"
@hightemp
hightemp / gist:5398061
Last active December 16, 2015 07:19
Different ways to format time and date using JavaScript

Format #1: date-month-year

var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth();
var curr_year = d.getFullYear();
document.write(curr_date + "-" + curr_month + "-" + curr_year);
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/

#PHP Snippets

##Transliterate

<?php
function transliterate($text, $lowercase=true) 
{
  static $smap, $chars, $regex, $maps;

###Dump data from sqlite

sqlite3 some.db .sch > schema
sqlite3 some.db .dump > dump
grep -v -f schema dump > data

###Load data from file

cat data | sqlite3 database.db

Unlock sqlite database

ActiveRecord::Base.connection.execute("BEGIN TRANSACTION; END;")