Skip to content

Instantly share code, notes, and snippets.

View tmazur's full-sized avatar

Tomasz Mazur tmazur

View GitHub Profile
@tmazur
tmazur / clickClear.js
Created October 27, 2012 18:39
Javascript: clickclear
$('.clickclear').each(function(){
$(this).data('cc-i-val',this.value);
}).click(function(){
if(this.value==$(this).data('cc-i-val'))
this.value='';
});
@tmazur
tmazur / isNumeric.js
Created October 27, 2012 18:40
Javascript: isNumeric
function isNumeric(input) {
return (input - 0) == input && input.length > 0;
}
@tmazur
tmazur / isValidEmail.js
Created October 27, 2012 18:41
Javascript: isValidEmail
function isValidEmail(emailAddress) {
var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
return pattern.test(emailAddress);
};
@tmazur
tmazur / robot.js
Created December 5, 2012 09:18
Zolmeister
var Robot = function(robot){
robot.turnLeft(robot.angle % 90);
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
if (robot.parentId) {
robot.ahead(1);
robot.turnGunRight(1);
}
else {
@tmazur
tmazur / robot.js
Created December 5, 2012 09:21
TM
function Robot(robot) {
robot.clone()
}
// well, we need to do something...
// whenever our robot is idle, this method gets called.
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
if(robot.parentId) {
robot.turn(10);
@tmazur
tmazur / AppModel.php
Created March 10, 2014 20:11
CakePHP: get session user_id from inside model
/**
* get user_id from session
* @return int current user_id
*/
public function getUserId() {
App::uses('CakeSession', 'Model/Datasource');
return CakeSession::read('Auth.User.id');
}
@tmazur
tmazur / gist:b6a396f543facc7a01cf
Created August 8, 2014 11:52
Launch Cygwin in current directory with login shell (works in Freecommander)
C:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico /bin/env CHERE_INVOKING=1 /bin/bash --login
@tmazur
tmazur / gist:ef170ad8ad896e037e4d
Last active August 29, 2015 14:06
Remove password protected PDF securities (print protection) using linux ghostscript
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sPDFPassword=password -sOutputFile=OUTPUT.pdf -c .setpdfwrite -f input.pdf
@tmazur
tmazur / utral2_build
Last active August 29, 2015 14:17
SublimeText build system using bash
{
"cmd": ["c:\\cygwin64\\bin\\bash.exe", "-l", "-c", "cd `cygpath -u \"${file_path}\\Utils\"` && buildl2"],
"working_dir": "${file_path}\\Utils\\",
"file_regex": "Label.h"
}
".workspace":
'alt-+': 'cursor-history:next'
'alt--': 'cursor-history:prev'
'ctrl-alt-o': 'native!'
'ctrl-alt-p': 'symbols-tree-view:toggle'
'.editor':
'ctrl-alt-right': 'atom-ctags:go-to-declaration'
'ctrl-alt-left': 'atom-ctags:return-from-declaration'
'ctrl-alt-o': 'native!'
'alt-b': 'build:toggle-panel'