Skip to content

Instantly share code, notes, and snippets.

View Hagith's full-sized avatar
👨‍💻
Working from home

Rafał Gałka Hagith

👨‍💻
Working from home
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
var db;
// https://developer.mozilla.org/en/IndexedDB/Using_IndexedDB
var indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB || window.msIndexedDB;
@Hagith
Hagith / cli.sh
Created September 13, 2013 14:25
grunt
web-build ./ -e "node_modules*" -e "nbproject*" -e ".git*" -e "Gruntfile.js" -e "package.json" -e "/.*" --output .build ./
cd .build/
web-signing -p r.galka
web-packaging -o -n ../shabetteconcier.wgt ./
web-install -w widget.wgt
@Hagith
Hagith / blob_base64.js
Created September 11, 2013 10:19
blob <-> base64
var data = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." ;
var blob = new Blob([data], {
type : "text/plain"
//type : "text/plain; charset=x-user-defined"
//type : "text/plain; charset=utf8"
});
blobToBase64(blob, function(b64) { // convert BLOB to BASE64
var newBlob = base64ToBlob(b64) ; // convert BASE64 to BLOB
$('body').html(blob.size + " != " + newBlob.size) ;
@Hagith
Hagith / tizen.js
Created September 4, 2013 10:18
Tizen init
document.querySelector('body').classList.add('tizen');
if (!window.indexedDB) {
window.indexedDB = window.webkitIndexedDB;
}
if (!window.MutationObserver) {
window.MutationObserver = window.WebKitMutationObserver;
}
document.addEventListener('tizenhwkey', function(e) {
@Hagith
Hagith / ajax2xmlhttprequest.js
Created August 20, 2013 08:02
Simple $.ajax to XMLHttpRequest
jQuery.ajax = function(opts) {
var xhr = new XMLHttpRequest({mozSystem: true});
var method = opts.type || 'GET';
method = method.toUpperCase();
if ('POST' !== method && opts.data) {
opts.url += '?' + jQuery.param(opts.data);
}
xhr.open(method.toUpperCase(), opts.url);
xhr.responseType = opts.dataType || 'json';
xhr.onreadystatechange = function () {
@Hagith
Hagith / drawing-tools.html
Created June 12, 2013 14:45
Google Maps v3 Drawing Tools
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="UTF-8">
<title>Drawing Tools</title>
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false&libraries=drawing"></script>
<style type="text/css">
#map, html, body {
@Hagith
Hagith / website-mirror.sh
Created April 11, 2013 12:54
Create a mirror of a website with Wget
#!/bin/bash
if [[ '' == $1 || '' == $2 ]]; then
echo "Provide domain name and URL"
exit 1
fi
wget \
--recursive \
--no-clobber \
@Hagith
Hagith / lftpsync
Created April 5, 2013 07:54
Sync files over network
## LFTP
lftp -c "set ftp:list-options -a;
open ftp://${FTP_USER}:${FTP_PASSWD}@${FTP_HOST};
lcd ${SOURCE_PATH};
cd ${DEST_PATH};
mirror --reverse \
--delete \
--verbose \
--ignore-time \
@Hagith
Hagith / arrayConditionToString.php
Last active December 15, 2015 19:09
Convert array condition (similar to mongo where) to SQL where clause.
<?php
function arrayConditionToString(array $def, array &$parts = array(), $operator = 'AND')
{
foreach ($def as $k => $v) {
if (is_string($v) && 0 === strpos($v, ':')) {
$parts[] = ' (' . $v . ') ';
}