Skip to content

Instantly share code, notes, and snippets.

@bastianccm
bastianccm / openerp-server
Created February 9, 2012 08:36
opernerp-server startup script
#!/bin/sh
### BEGIN INIT INFO
# Provides: openerp-server
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
@bastianccm
bastianccm / openerp-web
Created February 9, 2012 08:41
opernerp-web startup script
#!/bin/sh
### BEGIN INIT INFO
# Provides: openerp-web
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
thebod:~/Dropbox/fib_c$ wc -c fib.c
98 fib.c
thebod:~/Dropbox/fib_c$ cat fib.c
f(x){return x>1?f(x-1)+f(x-2):x;}main(int i,int**v){for(i=0;i<atoi(v[1]);)printf("%i\n",f(i++));}
thebod:~/Dropbox/fib_c$ gcc -o fib fib.c
fib.c: In function ‘main’:
fib.c:1: warning: incompatible implicit declaration of built-in function ‘printf’
thebod:~/Dropbox/fib_c$ ./fib 10
0
1
@bastianccm
bastianccm / thebod.zsh-theme
Created October 15, 2012 06:56
Oh My Zsh Theme
if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="yellow"; fi
PROMPT='%{$fg[$NCOLOR]%}%n%{$reset_color%}:%{$fg[blue]%}%0~%{$reset_color%}$(git_prompt_info)%(!.#.$) '
RPROMPT='[%*] %{$fg[blue]%}%m%{$reset_color%}'
# git theming
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg_bold[blue]%}(%{$fg_no_bold[yellow]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg_bold[blue]%})%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=""
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_bold[red]%}!"
print 10-sum([sum(map(int,str(int(v)*(2-k%2)))) for k,v in enumerate("271828182845856")])%10
<?php
// [...]
/**
* pregenerate missing attribute options
*
* @param array $products
*/
public function pregenerateAttributeOptions($products)
@bastianccm
bastianccm / Observer.php
Last active December 20, 2015 00:29
app/code/local/Mage/Catalog/Model/Observer.php, extended version including caching for topmenu, can save up to 200ms page loading - will be available as a module sooner or later ;-) Instead of always parsing the whole category layer to identify the active category the whole category structure is cached and only the data tree is parsed and the ne…
<?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
@bastianccm
bastianccm / composer.json
Created September 7, 2013 13:45
php composer.phar install
{
"require": {
"connect20/mage_all_latest": "1.7.*"
},
"repositories": [
{
"type": "composer",
"url": "http://packages.firegento.com/"
}
],
<?xml version="1.0"?>
<!--
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
@bastianccm
bastianccm / persistent.php
Created July 2, 2014 12:29
Persistent Magento
<?php
// put in magento root folder
// run via
// rm /tmp/magento; php persistent.php
// output is in /tmp/magento.log
function plog($msg) {
file_put_contents('/tmp/magento.log', date('H:i:s') . ': ' . $msg . PHP_EOL, FILE_APPEND);
}