Skip to content

Instantly share code, notes, and snippets.

View pnowosie's full-sized avatar

Pawel Nowosielski pnowosie

View GitHub Profile
@pnowosie
pnowosie / package.json
Last active August 29, 2015 14:01
Generating 10 digits pin code based on triplesec scrypt hash function
{
"name": "3sec-pin-generator",
"version": "0.0.0",
"description": "Generating 10 digits pin code based on triplesec scrypt hash function",
"dependencies": {
"triplesec": "^3.0.10",
"colors": "0.6.2"
},
"devDependencies": {},
"scripts": {
@pnowosie
pnowosie / pg_naming.cs
Last active August 29, 2015 14:02
PG table <-> class name conversion (Quick and dirty approach)
// LINQPad code
// Assumptions:
// Any uppercase letter in class name is made lowercase and (except first) prepend with underscore
// Underscores from table name are removed and letter following them are made uppercase (first is also made upper)
// Class name <-> Table name
// "InvoiceLineItems" "invoice_line_items"
void Main()
@pnowosie
pnowosie / keybase.md
Created June 25, 2014 12:56
Keybase github's identity proof

Keybase proof

I hereby claim:

  • I am pnowosie on github.
  • I am pnowosie (https://keybase.io/pnowosie) on keybase.
  • I have a public key whose fingerprint is 7512 0F42 7C38 7DC8 8B7B 574F BCD8 5298 2438 91

To claim this, I am signing this object:

var fs = require('fs-extra');
module.exports.Play = function(inputDir, outputDir) {
fs.exists(outputDir, function(exists) {
if (exists) throw new Error('Output directory already exists!');
fs.mkdir(outputDir, function(err){
if (err) throw err;
public class Lazy<T>
{
private Func<T> _evaluate;
private T _value;
public Lazy(Func<T> evaluate)
{
_evaluate = evaluate;
}
@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
// At this point, I'd like to take a moment to speak to you about the Adobe PSD
// format. PSD is not a good format. PSD is not even a bad format. Calling it
// such would be an insult to other bad formats, such as PCX or JPEG. No, PSD
// is an abysmal format. Having worked on this code for several weeks now, my
// hate for PSD has grown to a raging fire that burns with the fierce passion
// of a million suns.
//
// If there are two different ways of doing something, PSD will do both, in
// different places. It will then make up three more ways no sane human would
// think of, and do those too. PSD makes inconsistency an art form. Why, for
@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;