Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am gorosz on github.
  • I am georosz (https://keybase.io/georosz) on keybase.
  • I have a public key ASCtg57nIisQtBcb9SwRJiQEgbEcbHLidePLoDOPx_l9MQo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am gorosz on github.
  • I am georosz (https://keybase.io/georosz) on keybase.
  • I have a public key ASCDLDvMkUvp4gI1yE9wO9VzRWqxVYu06gGj0h9pbPI3cAo

To claim this, I am signing this object:

while true
do
# (1) prompt user, and read command line argument
read -p "Run the cron script now? " answer
# (2) handle the input we were given
case $answer in
[yY]* ) /usr/bin/wget -O - -q -t 1 http://www.example.com/cron.php
echo "Okay, just ran the cron script."
break;;
@gorosz
gorosz / readfromstdin.scala
Created August 11, 2016 07:15
Read from stdin scala hackerrank
val sc = new java.util.Scanner (System.in);
var n = sc.nextInt();
var arr = new Array[Int](n);
for(arr_i <- 0 to n-1) {
arr(arr_i) = sc.nextInt();
}
@gorosz
gorosz / get python function body
Created October 14, 2014 10:10
Sublime Text plugin
x, y = self.view.rowcol(self.view.sel()[0].begin())
tp = self.view.text_point(x, 0)
func_region = self.view.find(r'(?s)(?<=def)(.+?)(?=return)', tp)
func_text = self.view.substr(func_region)
@gorosz
gorosz / web2py
Created October 1, 2014 18:27
optional ldpa login
ldap_options = ldap_auth(
68 mode='ad',
69 server='ip',
70 base_dn='OU=xx,OU=xx,DC=xx,DC=xx,DC=com',
71 manage_user=True,
72 user_firstname_attrib='displayName:2',
73 user_lastname_attrib='displayName:1',
74 user_mail_attrib='mail',
75 db=db)
76 if settings.ldap:
@gorosz
gorosz / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
https://www.jeffknupp.com/writing-idiomatic-python-ebook/
http://docs.python-guide.org/en/latest
http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html
http://www.pythoncentral.io
http://planetpython.org
@gorosz
gorosz / itmoney_global.js
Created March 10, 2014 09:24
[javascript] - ajax callback
$.ajax({
url: url,
type: 'POST',
success: function(data) {
l.stop();
caller.prepend(successElement);
},
error: function(xhr, ajaxOptions, thrownError) {
alert('Error: {0}'.format(xhr.responseText));
}
@gorosz
gorosz / urlpharser.js
Created February 19, 2014 20:43
[javascript] - urlPharse
function urlPharser(url) {
console.log("init");
this.url = url;
this.prot = this.url.protocol;
this.host = this.url.host;
this.pathname = this.url.pathname;
this.vars = replaceAll("=", ":", this.url.search.slice(1, this.url.search.length));
this.vars = replaceAll("&", ",", this.vars);
//this.vars = JSON.parse(this.vars)
console.log(this.vars);