Skip to content

Instantly share code, notes, and snippets.

View daGrevis's full-sized avatar
⌨️
Keyboard operator

Raitis Stengrevics daGrevis

⌨️
Keyboard operator
View GitHub Profile
@daGrevis
daGrevis / gist:2819586
Created May 28, 2012 14:56
Gets images from web page and saves it locally
import os
import sys
import urllib
from pyquery import PyQuery
url = 'http://dagrevis.lv'
selector = 'img'
storage_dir = 'temp'
@daGrevis
daGrevis / gist:2870126
Created June 4, 2012 18:44
check_fields()
/**
* Helper: Provides that only meant database fields are changed.
*
* @param array $fields Fields (key, value pairs)
* @param array $expected Changeable fields (just keys)
* @throws HTTP_Exception_400 If any key of 1st array is not found in 2nd array, but is table column
*/
function check_fields($fields, $changeable) {
$field_keys = array_keys($fields);
<?php
/**
* Squiz_Sniffs_Strings_ConcatenationSpacingSniff.
*
* PHP version 5
*
* @category PHP
* @package PHP_CodeSniffer
* @author Greg Sherwood <gsherwood@squiz.net>
* @author Marc McIntyre <mmcintyre@squiz.net>
@daGrevis
daGrevis / regexilioucieus.php
Created June 7, 2012 12:13
regexilioucieus
<?php
function symbolCheck($input) {
return preg_match('/^[\pL0-9\:\/\.\_\-]/uD', $input);
}
$cases = array(
'abc:',
$(function() {
var draw_quote = function($el) {
Raphael($el[0], 32, 24)
.path('M32,24V12h-8c0-4.41,3.586-8,8-8V0c-6.617,0-12,5.383-12,12v12H32z M12,24V12H4c0-4.41,3.586-8,8-8V0C5.383,0,0,5.383,0,12v12H12z')
.attr({
'fill': 'black'
})
;
$(function() {
var $blockquote = $('blockquote');
if ($blockquote.length) {
var $quote = $('<div />');
Raphael($quote[0], 32, 24)
.path('M32,24V12h-8c0-4.41,3.586-8,8-8V0c-6.617,0-12,5.383-12,12v12H32z M12,24V12H4c0-4.41,3.586-8,8-8V0C5.383,0,0,5.383,0,12v12H12z')
@daGrevis
daGrevis / xmonad.hs
Created June 26, 2012 20:10
xmonad.hs
import XMonad
import XMonad.Util.EZConfig
main = xmonad $ defaultConfig { terminal = "xterm" }
`additionalKeysP`
[ ("<Print>", spawn "scrot '%Y-%m-%d_%s.png' -e 'mv $f ~/Screenshots/'") ]
@daGrevis
daGrevis / boilerplate.js
Created June 30, 2012 13:40
Boilerplate for jQuery plugin
(function($){
$.fn.my_plugin = function() {
return this.each(function() {
var self = this;
console.log($(self));
@daGrevis
daGrevis / gist:3090169
Created July 11, 2012 12:47
Git alias
[dagrevis@localhost Dotfiles]$ gs
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: .bashrc
#
no changes added to commit (use "git add" and/or "git commit -a")
[dagrevis@localhost Dotfiles]$ ga .
@daGrevis
daGrevis / gets_tld_in_django.py
Created August 8, 2012 07:31
Gets TLD in Django
''.join(request.META['HTTP_HOST'].split('.')[-1:]).split(':')[0]