Skip to content

Instantly share code, notes, and snippets.

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

Moises Brenes ksysctl

🏠
Working from home
View GitHub Profile
@ksysctl
ksysctl / gist:8345017
Created January 10, 2014 00:51
Get objects by specific day
# created_at is a DateTime field
from datetime import datetime
today = datetime.now()
objs = MyModel.objects.filter(
created_at__day=today.day,
created_at__month=today.month,
created_at__year=today.year
)
@ksysctl
ksysctl / clue_flacs.sh
Last active December 21, 2015 03:38
Split cue into individual flac files
#!/bin/bash
#
# author: @gin, 2013
# url:
#
# split cue into individual flac files
#
# dependencies:
# sudo apt-get install flac bchunk ffmpeg
#
@ksysctl
ksysctl / gist:6242334
Created August 15, 2013 16:38
Split cue into individual flac files
# dependencies
sudo apt-get install flac bchunk ffmpeg
# convert to a wave file
ffmpeg -i INPUT.ape OUTPUT.wav
# split the .wav into individual tracks
bchunk -w OUTPUT.wav INPUT.cue BASE_FILENAME
# convert to flac
@ksysctl
ksysctl / gist:6208546
Created August 12, 2013 06:01
How I installed nvidia driver for Debian Jessie(unstable)
apt-get install --install-recommends --install-suggests nvidia-kernel-dkms nvidia-glx nvidia-xconfig
reboot
@ksysctl
ksysctl / gist:6201577
Created August 10, 2013 18:28
Change dictionary keys in a list
# Original list of dicts
old = [{
'product_name': 'A Name',
'product_id': '666'
}]
# New keys
mapping = {
'product_name': 'name',
'product_id': 'id'
@ksysctl
ksysctl / gist:6201563
Created August 10, 2013 18:25
Detect DOM modified
$('#element').bind('DOMSubtreeModified',function() {
// do something
});
@ksysctl
ksysctl / gist:6092304
Last active December 20, 2015 07:19
Get today string zero padded
today = new Date();
today = '' +
('000' + today.getFullYear()).slice(-4) +'-'+
('0' + today.getMonth()).slice(-2) +'-'+
('0' + today.getDay()).slice(-2);
/* today is:
####-##-## (YYYY-MMM-DD)
sample:
@ksysctl
ksysctl / skype.sh
Created May 6, 2013 19:38
Install Skype 4.1 i386 package on Debian Multi-Arch amd64/system
sudo dpkg --add-architecture i386;
sudo apt-get update;
sudo apt-get install libpulse0:i386;
wget -O skype-install.deb http://www.skype.com/go/getskype-linux-deb;
sudo dpkg -i skype-install.deb;
sudo apt-get install -f;
@ksysctl
ksysctl / configurable.phtml
Created April 9, 2013 22:17
Get quantity for every simple product that build a configurable product in Magento
<?php
// $_product = $this->getProduct();
$stock = 0;
$simpleProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $_product);
foreach ($simpleProducts as $simple) {
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($simple);
if ($stockItem->getIsInStock()) {
$qty = intval($stockItem->getQty());
$stock += $qty;
@ksysctl
ksysctl / set_stock_cfg.sql
Created April 2, 2013 15:43
Set stock status for every configurable product on Magento only if has an image
UPDATE
`cataloginventory_stock_item`
SET
`cataloginventory_stock_item`.`is_in_stock` = '1'
WHERE
`cataloginventory_stock_item`.`product_id` IN
(
SELECT
a.entity_id
FROM