Skip to content

Instantly share code, notes, and snippets.

View corpix's full-sized avatar
👹
Fighting demons

corpix corpix

👹
Fighting demons
View GitHub Profile
@corpix
corpix / redactor-trigger-changed-on-textarea-example.js
Created March 16, 2012 11:48
Redactor. Trigger change event for single page apps
setCodeTextarea: function(code)
{
this.$el.val(code).trigger('change');
}
@corpix
corpix / increase-img-size-on-mouseenter.js
Created March 16, 2012 13:36
Increases image size on mouse enter
$(function(){
$('img.expand').each(function(key, el){
var $el = $(el)
, image
, originalWidth, originalHeight
, width, height;
width = $el.attr('width');
height = $el.attr('height');
@corpix
corpix / fedora-env.sh
Created March 24, 2012 03:08
Fedora env
# Fedora 17 x86_64
cd /tmp
yum install -y gnome-tweak-tool light-theme-gnome gconf-editor && \
su corpix -c 'dconf write /org/gnome/shell/overrides/button-layout \'"close,minimize,maximize:"\'' && \
wget http://font.ubuntu.com/download/ubuntu-font-family-0.80.zip
CHROME_REPO="/etc/yum.repos.d/google-chrome.repo"
@corpix
corpix / String-to-dot-notation.js
Created March 25, 2012 21:39
Get value from object by string
var obj = {
a: {
b: 1
}
}
'a.b.etc'.split('.').reduce(function (obj,i) {
return 'object' == typeof obj ? obj[i] || false : false;
}, obj);
@corpix
corpix / OwnCloud.nginx.conf
Created April 29, 2012 15:35
Own Cloud nginx config
server {
listen 80;
server_name cloud.yourhost.ru;
rewrite ^ https://$server_name$request_uri? permanent;
}
# HTTPS
server {
listen 443 ssl;
server_name cloud.yourhost.ru;
@corpix
corpix / www.conf
Created April 29, 2012 15:56
php-fpm config
[www]
listen = /var/run/php-fpm/php-fpm.sock
listen.owner = php-fpm
listen.group = php-fpm
listen.mode = 0666
user = php-fpm
group = php-fpm
@corpix
corpix / wide-normal.js
Created May 12, 2012 00:15
Make me wide, make me normal
// Wide
function () {
$(this).find('img.normal').fadeOut(300);
$(this).find('img.wide').fadeIn(300);
$(this).animate({ width: '340px', height: '134px' }, 200);
$(this).parent().animate({ top: '-16px', left: '-17px' }, 200);
$(this).parent().css('z-index', '100');
};
@corpix
corpix / for-forEach-example.js
Created May 23, 2012 21:25
for,forEach loops example
var obj, key, arr;
obj = {
foo: 'bar',
baz: 'faz'
};
for(key in obj){
console.log(key, ':', obj[key]);
}
@corpix
corpix / test.loops.sync.js
Created May 26, 2012 09:58
test.loops.sync
var i = 0;
console.log('Setting timeout');
setTimeout(function(){
console.log('Timeout callback raised');
}, 500);
console.log('Beginning of the loop')
while(true){
i++;
@corpix
corpix / test.loops.async.js
Created May 26, 2012 09:58
test.loops.async
var i = 0;
console.log('Setting timeout(500)');
setTimeout(function(){
console.log('Timeout callback raised');
}, 500);
process.nextTick(function(){
console.log('Beginning of the loop');
while(true){