Skip to content

Instantly share code, notes, and snippets.

View pnowosie's full-sized avatar

Pawel Nowosielski pnowosie

View GitHub Profile
@pnowosie
pnowosie / translation-views
Created June 28, 2012 10:35
View translations, snippets, metadata and language
select TOP 200
MD.Id mId
,MD.Code Metadata
,L.Name Lang
,S.Id sId
,S.LabelCode Snippet
,T.Text
from [dbo].[BaseTranslation] T
@pnowosie
pnowosie / Oziris2Pets.js
Created October 31, 2012 18:20
Oziris time (h:mm) to PETS time (h,hh)
$('.k-focusable').find('td').each(function(ind,elt) {var t,h,mm; if((t = elt.innerText).match(/^\d+:\d\d$/)) { h = t.split(':')[0], mm = t.split(':')[1]; mm = Math.round((mm/6.0)*10); elt.innerText = h + ',' + (mm<10 ? '0':'') + mm } })
@pnowosie
pnowosie / gist:4547778
Created January 16, 2013 15:07
Image optimization using optipng for PNG and jpegtran for JPEG images
## Image optimization
## Dependencies:
## * optipng http://optipng.sourceforge.net/
## * jpegtran http://jpegclub.org/jpegtran/
# JPEG
$files = ls -Name -Recurse -Include("*.jpg", "*.jpeg")
$i = 0
foreach ($f in $files) {
echo "Optimizing file: $f"
@pnowosie
pnowosie / gist:5081692
Created March 4, 2013 11:32
Random strings generator. String chars are between 32 (space) and 32+94 (~)
// LinqPad test
void Main()
{
int testNum = 1000, length = 32;
int testRun = 0;
while (testNum-- > 0)
{
string testString = GetRandomString(length);
if (testString.All(c => ((int)c >= 32 && (int)c <= 32+94)))
++testRun;
@pnowosie
pnowosie / gist:5231580
Last active December 15, 2015 08:29
Script creates local git repository linked with bare "remote" copy in dropbox directory, so you gain cloud backups ater pushing changes.
# Script creates local git repository linked with bare "remote" copy in dropbox directory,
# so you gain cloud backups ater pushing changes.
# Add following function to you PS Profile (don't forget to restart the shell)
#-----------------------------------------------------------------
# Git-Init
#-----------------------------------------------------------------
$boxRepoPath = '{PATH_TO_DROPBOX_DIR where repos will be stored}'
function Git-Init($repoName $(throw "Parameter repoName is required.")) { # run inside directory where you want working copy to put
@pnowosie
pnowosie / gist:5429909
Last active December 16, 2015 11:49
TDD with jasmine and coffeescript on node
#
# DEPENDENCIES
# ------------
# * coffee-script (npm install -g coffee-script)
# * jasmine-node (npm install -g jasmine-node)
#
# Test directories structure:
# ---------------------------
# . [ROOT]
# - src
public string Octal(int n) {
if (n < 0) return "-" + Octal(-n);
if (n < 8) return n.ToString();
var s = new StringBuilder();
while (n > 0) {
s.Append(n % 8);
n /= 8;
}
@pnowosie
pnowosie / padLeft.js
Last active December 17, 2015 18:58
Javascript PadLeft function padLeft(15, 4) => '+0015', padLeft(15, 4, false, '*') => '+**15', padLeft(15, 4, true, '*') => '**15'
var padleft = function(number, count, abs, padChar) {
count--;
if (count < 0) count = 0;
var str = '';
if (number < 0) { number = -number; str += '-'; } else str += '+';
if (abs) str = '';
if (!padChar) padChar = '0';
var mltp = 10;
while (count > 0) {
@pnowosie
pnowosie / SimpleAutoVersion.ps1
Last active December 20, 2015 16:18
Simple autoversioning PS script. It checks out repositories listed in file 'repo.txt' and replaces AssemblyVersion attribute value from 'SharedAssemblyInfo.cs' to the new one and then builds solution and check-in modified AssemblyVersion
## TODO: Add header, licence ...
# Missing parts:
# * Error handlig
# * User friendly configuration and customization
# * Usage info
# ===== Configuration ==== #
$SVNCMD = "C:\Program Files\TortoiseSVN\bin\svn.exe"
$BUILDTOOL = "C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe"
@pnowosie
pnowosie / Tables_row_count.sql
Created September 23, 2013 10:11
Sql batch calculates row count for each table in given database. Executes dynamic sql and gets value into output variable
-- @description:
-- Print rows count for every table in given database
DECLARE
@Report_type smallint = 1; -- set 0 for 'ALL_TABLES', 1 for non-empty tables
DECLARE
@database varchar(128) = 'UsageAndHealthDB',
@tbl_name varchar(128),
@tbl_cnt int = 0,