Skip to content

Instantly share code, notes, and snippets.

View gjergjsheldija's full-sized avatar

Gjergj Sheldija gjergjsheldija

View GitHub Profile
@gjergjsheldija
gjergjsheldija / day_of_month.php
Created October 3, 2011 15:15
find first and last day of month
<?php
function firstDayOfMonth() {
return date("d", strtotime(date('m').'/01/'.date('Y').' 00:00:00'));
}
function lastDayOfMonth() {
return date("d", strtotime('-1 second',strtotime('+1 month',strtotime(date('m').'/01/'.date('Y').' 00:00:00'))));
}
@gjergjsheldija
gjergjsheldija / gconf-watcher
Created February 21, 2012 12:45
gconf-watcher
#!/usr/bin/env python
###
# Print out changes to the environment
###
import gtk, gconf
def key_to_tool(entry):
v = entry.value
try:
@gjergjsheldija
gjergjsheldija / gist:3099569
Created July 12, 2012 17:41
duplicate rows on table across multiple columns
select
distinct n1.bill_nr as first
from care_med_products_main_movements as n1
join care_med_products_main_movements as n2
on
n1.id_sub = n2.id_sub and
n1.bill_nr = n2.bill_nr and
n1.medicament = n2.medicament and
n1.qty = n2.qty and
n1.price = n2.price and
@gjergjsheldija
gjergjsheldija / create_changeset.sh
Created July 16, 2012 11:44
create hg changesets
#!/bin/bash
if [ $# -lt 3 ] ; then
cat <<HELP
create-changeset -- creates a tar.gz file with the changed files
USAGE: create-changeset 'repository-path' 'revision-from' 'revision-to'
EXAMPLE: create-changeset /var/www/survey 4 5
@gjergjsheldija
gjergjsheldija / cap_first.sql
Created August 30, 2012 17:36
upper case first char
DELIMITER //
CREATE FUNCTION CAP_FIRST (input VARCHAR(255)) RETURNS VARCHAR(255)
DETERMINISTIC
BEGIN
DECLARE len INT;
DECLARE i INT;
SET len = CHAR_LENGTH(input);
@gjergjsheldija
gjergjsheldija / gist:3832507
Created October 4, 2012 09:28
find number of occurrences in string
SELECT `order_nr` ,
(LENGTH( history ) - LENGTH( REPLACE( history, 'Received', '' ) )) / LENGTH( 'Received' ) AS occurrences
FROM care_pharma_orderlist
@gjergjsheldija
gjergjsheldija / gist:4194848
Created December 3, 2012 12:51
postgres change column from boolean to inetger
ALTER TABLE table_name ALTER column_name SET DEFAULT null;
ALTER TABLE table_name
ALTER column_name TYPE INTEGER
USING
CASE
WHEN false THEN 0
ELSE 1
END;
<?xml version="1.0"?>
<project name="project_sync" basedir="." default="-init">
<property name="version" value="4.0" />
<!-- Public targets -->
<!-- ============================================ -->
<!-- Target: sync:list -->
<!-- ============================================ -->
<target name="sync:list" description="Public: List files to be synchronized facade">
<phingcall target="-sync-execute-task">
<property name="listonly" value="true" />
@gjergjsheldija
gjergjsheldija / make_djvu.sh
Created April 4, 2013 19:27
create djvu books for subdirs of scanned images into low and hi res
#!/bin/sh
UNPAPER_OPTS_COMMON=" --mask-scan-threshold 0.01 --dpi 600 --mask-scan-size 100"
UNPAPER_OPTS_ST1=" --deskew-scan-size 5000 -dv 0.5"
UNPAPER_OPTS_ST2=" --no-noisefilter --no-blackfilter --no-grayfilter --no-blurfilter --no-deskew --border-align top --border-margin 150"
sdir=`pwd` #starting point; it is important that you start at the right place
dir=`find . -type d` #will save the sub/directory tree in var

Keybase proof

I hereby claim:

  • I am gjergjsheldija on github.
  • I am gjergjsheldija (https://keybase.io/gjergjsheldija) on keybase.
  • I have a public key whose fingerprint is 38EB F6EC E744 35F7 B87A B1E8 AE1E 229F F34F C0D3

To claim this, I am signing this object: