Skip to content

Instantly share code, notes, and snippets.

View ypetya's full-sized avatar
💭
🚀

Peter Kiss ypetya

💭
🚀
  • Budapest, Hungary
View GitHub Profile
@ypetya
ypetya / .bashrc
Last active August 29, 2015 14:12
*require* bash function
function is_installed() {
local installed=$(dpkg -s "$1" 2>&1 | grep 'install ok installed')
if [ "" == "$installed" ] ; then
return 1
fi
return 0
}
function require() {
UNAME="$(uname)"
@ypetya
ypetya / save-temperature-to-db.sh
Last active August 29, 2015 14:11
Raspberry bash scripts for temperature webservice and backend. + Take a photo example
#!/bin/bash
#
# @author: Peter Kiss <[email protected]>
#
# this script reads and saves the humidity and temperature sensor data to an
# sqlite database database
#
readonly SENSORS=( /dev/ttyACM0 )
readonly TEMPERATURE_DB_FILE="temperature.sqlite.db"
@ypetya
ypetya / Gmail fapad.js
Created December 4, 2014 09:26
Tampermonkey user scripts
// ==UserScript==
// @name Gmail fapad
// @namespace http://*.google.com
// @version 0.1
// @description enter something useful
// @author [email protected]
// @match http*://mail.google.com/*
// ==/UserScript==
// @ REM grant unsafeWindow
// @ REM require http://code.jquery.com/jquery-latest.js
@ypetya
ypetya / arduino.md
Last active August 29, 2015 14:10
Playing with Hardware-stuff - POC

Monitoring DHT11 humidity and temperature sensor

Step 1. install preresquites on ubuntu

apt-get install arduino arduino-core
# add necessary usergroups relogin or restart
arduino
@ypetya
ypetya / Readme.md
Last active August 29, 2015 14:07
javascript prototype inheritance, apply, call, Object.create

Prototype inheritance

It can be implemented in multiple ways

  • using call and apply functions to change the scope of the this keyword
  • using the ECMA5 feature Object.create

examples for

  • apply
  • call
@ypetya
ypetya / git_tweak.md
Last active April 11, 2016 09:44
Windows tweaks

$ git config --global core.preloadindex true $ git config --global core.fscache true $ git config --global gc.auto 256

@ypetya
ypetya / printFunctions.js
Last active August 29, 2015 14:06
Print out javascript object's functions to the console. Originates from http://stackoverflow.com/questions/5842654/javascript-get-objects-methods
var printFunctions = function(myObject){
var funcs = []
for(var name in myObject) {
if(typeof myObject[name] === 'function') {
funcs.push(name)
}
}
console.info(push.sort());
}
@ypetya
ypetya / diacriticsReplacer.js
Created September 18, 2014 08:19
Replace diacritics in javascript.
var replaceDiacritics = function (string) {
var diacritics = [
/[\300-\306]/g, /[\340-\346]/g, // A, a
/[\310-\313]/g, /[\350-\353]/g, // E, e
/[\314-\317]/g, /[\354-\357]/g, // I, i
/[\322-\330]/g, /[\362-\370]/g, // O, o
/[\331-\334]/g, /[\371-\374]/g, // U, u
/[\321]/g, /[\361]/g, // N, n
/[\307]/g, /[\347]/g, // C, c
];
@ypetya
ypetya / gi_index.json
Last active August 29, 2015 14:06
glikemias index
{
"Kukorica szirup": 115,
"Sör": 110 ,
"Szőlőcukor": 100 ,
"Cukor szirup": 100 ,
"Sült krumpli": 95 ,
"Maltodextrin": 95 ,
"Burgonya keményitő": 95 ,
"Burgonya, kemencében sütött": 95 ,
"Rizs liszt": 95 ,
@ypetya
ypetya / get-proxies-function.sh
Last active August 29, 2015 14:06
getproxies bash function. Call it with the PAC proxy url. It will try to use it with curl connecting to githubs https to check wether this PROXY is good for https connection or not.
# use with argument $1 - proxy auto discovery address
function getproxies() {
PROXIES=( $(curl $1 2>/dev/null | perl -ne 'if(/PROXY ([^";]*)/g){ print "$1\n";}'))
for proxy in ${PROXIES[*]} ; do
if "curl" -s -x $proxy --connect-timeout 5 https://github.com &> /dev/null ; then
echo "$proxy : OK"
else
echo "$proxy : not working $?"
fi
done