Skip to content

Instantly share code, notes, and snippets.

@alechko
alechko / consolelog.js
Created February 4, 2018 08:01
JS Timestamp for console log
var now = new Date();
var h = now.getHours();
h = h > 9 ? h : '0'+h;
var m = now.getMinutes();
m = m > 9 ? m : '0'+m;
var s = now.getSeconds();
s = s > 9 ? s : '0'+s;
var ms = now.getMilliseconds();
n = '['+h+':'+m+':'+s+'.'+ms+'] '+n;
console.log(n,item);
@alechko
alechko / gist:e89f1add77e557cdda423d54543d97ce
Created June 5, 2017 07:09
resize multiple icons with convert
for i in $(ls | cut -f1 -d. | uniq); do convert -resize 24 $i.png $i-24.png; done
@alechko
alechko / cairo-scaled-font-fix.sh
Created December 6, 2015 06:07
fixing "../../../../src/cairo-scaled-font.c:459: _cairo_scaled_glyph_page_destroy: Assertion `!scaled_font->cache_frozen' failed."
# after upgrading wheezy or after dist-upgrade wheezy to jessie
# I was getting this error almost on every program like sublime text, gimp and many more
# ../../../../src/cairo-scaled-font.c:459: _cairo_scaled_glyph_page_destroy: Assertion `!scaled_font->cache_frozen' failed.
# here's what fixed it for me:
sudo dpkg-reconfigure fontconfig-config
# selecting "Native" -> "Automatic" -> "No"
# by that point everything was working good, but just to make sure run:
sudo dpkg-reconfigure fontconfig
@alechko
alechko / forked_repo
Created September 29, 2015 10:41
Working with forked repo
#!/bin/bash
# sometimes, when checking a pull request, I wanted to commit my own changes into the forked repo
# and return it to the developer for more work. I wanted to do that without cloning his repo.
# So what I'm doing is first, setup a remote:
git remote add [upstream_name] https://[myusername]@github.com/[remoteuser]/[repo].git
# you can see it now under
git remote -v
# then sync branches
git fetch [upstream_name]
# then I checkout to a new branch (if I didn't do it earlier)
@alechko
alechko / canon_shuttercount
Last active January 12, 2023 08:55
Get Canon EOS DSLR camera shutter count with gphoto2.
# connect your camera with USB cable, for 6D model you have to disable the WiFi first.
# then see if camera is connected by using:
gphoto2 --auto-detect
# if you see something like:
#
# user@x250:~$ gphoto2 --auto-detect
# Model Port
# ----------------------------------------------------------
# Canon EOS 6D usb:001,006
#
@alechko
alechko / jq
Created March 25, 2015 14:13
jQ noconflict
if (typeof jQuery != 'undefined') {
console.log(jQuery.fn.jquery);
} else {
var jq = document.createElement('script'); jq.type = 'text/javascript';
jq.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js';
document.getElementsByTagName('head')[0].appendChild(jq);
var j = jQuery.noConflict(true);
}
@alechko
alechko / pages.filter.inc
Created June 12, 2013 07:31
delete empty taxonomies
$query = db_select('taxonomy_term_data', 't');
$query->fields('t',array('tid'));
$query->condition('name','');
$tids = $query->execute()->fetchCol();
db_delete('taxonomy_term_data')
->condition('tid', $tids,'IN')
->execute();
@alechko
alechko / pages.js
Created June 11, 2013 07:44
Console log clicked event
$(document).click(function(e){
var clickElement = e.target; // get the dom element clicked.
var elementClassName = e.target.className; // get the classname of the element clicked
console.log(e);
});
@alechko
alechko / drupal_table_example.php
Last active December 18, 2015 06:39
Drupal table render example
<?php
// Table header
$header = array(
'fruit' => t('Fruit'),
'a' => t('Vitamin A'),
'b1' => t('Vitamin B1'),
'b2' => t('Vitamin B2'),
);
// Table rows
@alechko
alechko / node_creation.php
Last active December 18, 2015 03:39
Create node in drupal
<?php
// Create a node object, and add node properties.
$newNode = new stdClass();
$newNode->type = 'node_example';
$newNode->uid = 0;
$newNode->created = strtotime("now");
$newNode->changed = strtotime("now");
$newNode->status = 1;
$newNode->comment = 0;
$newNode->promote = 0;