Skip to content

Instantly share code, notes, and snippets.

View svenvarkel's full-sized avatar

Sven Varkel svenvarkel

View GitHub Profile
var Promise = require('bluebird');
var myType = 'mytype';
var nativePromise = new Promise(function (resolve, reject) {
sails.models[mytype].native(function (err, collection) {
if (err) {
return reject(err);
}
var pipeline = []; //some pipeline
collection.aggregate(pipeline).toArray(function (err, itemList) {
@svenvarkel
svenvarkel / mage.php
Created July 7, 2014 08:37
Patch for missing chdir in mage.php, the Magento command line script
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
@svenvarkel
svenvarkel / package_extension
Created July 2, 2014 09:20
Bamboo build step for packaging Magento extension
BUILDDIR=$1
CONNECTDIR="$BUILDDIR/public/var/connect"
PACKAGEXML="$CONNECTDIR/package.xml"
echo "Using package.xml: $PACKAGEXML"
cd $BUILDDIR/public
if [ -f "$PACKAGEXML" ];
then
./mage package $PACKAGEXML
@svenvarkel
svenvarkel / Package.php
Created July 1, 2014 20:49
Magento 1.* extension packager bug in lib/Mage/Connect/Command/Package.php
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide- web at this URL:
* http://opensource.org/licenses/osl-3.0.php
@svenvarkel
svenvarkel / kill_glassfish.sh
Created January 14, 2014 19:27
Kill glassfish easily, quickly and for sure: ./kill_glassfish.sh
#!/bin/bash
ps -ef | grep "[c]om.sun.enterprise.glassfish.bootstrap.ASMain" | awk '{print $2}' | xargs kill -9
@svenvarkel
svenvarkel / fix_permissions.sh
Created December 20, 2013 22:40
Fix file permissions in your Magento project folder. It has some constraints: - use group name "dev" for your developers and your "php/web server user" (www-data) - it's untested in other environments than Debian/Ubuntu
#!/bin/bash
#
# This script fixes permissions on Magento subtree
#
# Usage:
# cd to virtual host folder
# run script by issuing utils/fix_permissions.sh . command
#
# Author Sven Varkel <[email protected]>
# Copyright 2013 MageFlow Ltd
@svenvarkel
svenvarkel / .gitignore
Created December 4, 2013 09:25
A reference .gitignore file for Magento 1.* projects
#
# .gitignore version 1.0-beta
#
# For the reference see the folder structure here:
# http://measure9.varkel.net/2013/10/setting-up-magento-development-environment-step-by-step-part-3-naming-and-structure/
#
# System files, special files
#
.DS_Store
._*
@svenvarkel
svenvarkel / git-remove-large-files
Created December 4, 2013 08:46
This script helps to remove specified files or folders from the whole GIT repository history
#!/bin/bash
# 1. list git branches
# 2. iterate thru branches
# 3. for each branch do git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch FILENAME" HEAD
filepath=$1
remove_large_files(){
for branch in $(git branch)
do
echo "Removing ${filepath} from ${branch}"
git filter-branch -f --index-filter "git rm -rf --cached --ignore-unmatch ${filepath}" $branch
@svenvarkel
svenvarkel / git-find-large-files
Created December 4, 2013 08:44
This script finds the n largest files from your git repository.
#!/bin/sh
#
# Credits go to: http://article.gmane.org/gmane.comp.version-control.git/123050
#
usage() {
echo "usage: `basename $0` [<limit>]"
exit 1
}
@svenvarkel
svenvarkel / retrieve_magento_db_password.sh
Created October 28, 2013 10:39
This is a useful oneliner for reading Magento database password from local.xml in command line
#!/bin/bash
# run in your app/etc folder
grep -o -P "<password><\!\[CDATA\[([\w]*)\]\]><\/password>" local.xml | sed -e 's|<password><\!\[CDATA\[||g' | sed -e 's|\]\]></password>||g'