Skip to content

Instantly share code, notes, and snippets.

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

bjarneo bjarneo

🏠
Working from home
View GitHub Profile

Magento Code Snippets

Download extension manually using mage

./mage config-set preferred_state stable
./mage clear-cache
./mage sync
./mage download community Module_Name
@bjarneo
bjarneo / gist:4706975
Created February 4, 2013 14:23
Javascript Snippets

Javascript Snippets

Remove newline and whitespace from string. Todo: (merge regX)

function removeWhiteSpaceAndNewLine(myString) {
    var regX = /\n/gi;
    var regXs = /(\s)/gi;
    s = new String(myString);
    s = s.replace(regX, "");
 s = s.replace(regXs, "");

Magento Code Snippets

Download extension manually using mage

./mage config-set preferred_state stable
./mage clear-cache
./mage sync
./mage download community Module_Name
SET FOREIGN_KEY_CHECKS=0;
-- Customers
TRUNCATE `customer_address_entity`;
TRUNCATE `customer_address_entity_datetime`;
TRUNCATE `customer_address_entity_decimal`;
TRUNCATE `customer_address_entity_int`;
TRUNCATE `customer_address_entity_text`;
TRUNCATE `customer_address_entity_varchar`;
TRUNCATE `customer_entity`;

Magento Code Snippets

Download extension manually using mage

./mage config-set preferred_state stable
./mage clear-cache
./mage sync
./mage download community Module_Name
$now = time();
$cache_timer = get_option('frontpage_categories_box_cachetime', $now);
if ($cache_timer > $now) {
$content = get_option('frontpage_cateogires_box_content');
if (empty($content)) {
ob_start();
include 'views/frontpage_categories_box.php';
$content = ob_get_clean();
update_option('frontpage_cateogires_box_content', $content);
update_option('frontpage_categories_box_cachetime', (time() + (60 * 60)));
@bjarneo
bjarneo / isTransformSupported
Created January 21, 2015 11:38
JavaScript - css3 transform support
var isTransformSupported = function() {
var prefixes = [
'transform',
'WebkitTransform',
'MozTransform',
'OTransform',
'msTransform'
], len = prefixes.length;
while (len--) {
@bjarneo
bjarneo / strreplace
Created February 3, 2015 12:24
Recursive string replacement
find . -iname '*php' | xargs grep 'mysql' -sl | while read x; do echo $x; sed -i 's/mysql/mysqli/' $x; done
@bjarneo
bjarneo / Pushbullet
Last active August 29, 2015 14:15
Pushbullet - send basic note
#!/usr/bin/env python
import urllib
import urllib2
import base64
import json
config = {
'api': 'https://api.pushbullet.com/v2/pushes',
'token': 'your_token'
@bjarneo
bjarneo / pushover
Last active August 29, 2015 14:15
Pushover - send basic msg
#!/usr/bin/env python
import urllib
import urllib2
import json
config = {
'api': 'https://api.pushover.net/1/messages.json',
'user': 'user_key',
'token': 'your_token'