Skip to content

Instantly share code, notes, and snippets.

View RaVbaker's full-sized avatar
drinking coffee

Rafal Piekarski RaVbaker

drinking coffee
View GitHub Profile
@RaVbaker
RaVbaker / new-lang-code-file.php
Created November 6, 2011 00:34
How to create new programming language in PHP?
// This is written in pseudo language
class Foo {
def bar() {
ret "it Works!";
}
}
$f = Foo.new();
print $f.bar();
@RaVbaker
RaVbaker / readme.md
Created March 30, 2012 20:12
[HOWTO] Rewrite all urls to one index.php in Apache

Redirect All Requests To Index.php Using .htaccess

In one of my pet projects, I redirect all requests to index.php, which then decides what to do with it:

Simple Example

This snippet in your .htaccess will ensure that all requests for files and folders that does not exists will be redirected to index.php:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

@RaVbaker
RaVbaker / readme.md
Last active November 29, 2023 06:08
Reverse engineering Things SQLite tasks database

To open SQLite Things.app database run this command in Terminal.app:

$ sqlite3 ~/Library/Containers/com.culturedcode.things/Data/Library/Application\ Support/Cultured\ Code/Things/ThingsLibrary.db

In SQLite command-line type this query to get your tasks stats:

sqlite> .mode column
sqlite> .header on
sqlite> select zscheduler, zstatus, ztrashed, count(*) from ZTHING where z_ent = 13 group by  zstatus,ztrashed order by Z_pk desc;

ZSCHEDULER ZSTATUS ZTRASHED count(*)

@RaVbaker
RaVbaker / iOS5_update_checker.command
Created October 12, 2011 15:40
iOS5 software update notifier
#! /bin/csh
while (1)
curl -s -L http://phobos.apple.com/version | grep -i Restore | grep -i "\(iPhone\|iPad\|iPod\)" | grep -i "5\.0"
if ($? == 1) then
echo "Nothing yet..."`date`
else
say "iOS FIVE POINT OH FIRMWARE IS NOW AVAILABLE"
endif
sleep 13
end
@RaVbaker
RaVbaker / gist:6233181
Created August 14, 2013 17:14
[PHP] klasa do obsługi API Ceneo
<?php
/*
* Author: Rafał "RaVbaker" Piekarski <ravbaker @ gmail.com>
* Website: http://ravbaker.net/
* License: MIT
* Created in: 2013
*/
class CeneoApi {
@RaVbaker
RaVbaker / fetch_all.rb
Created June 5, 2012 20:34
YouTube Videos downloader
#!/usr/bin/env ruby -wKU
#### script requires wget app
# Copyright RaVbaker - MIT license
# list of video urls, each url in single line
videos = %w{
http://www.youtube.com/watch?v=lFJey0tOvBg
http://www.youtube.com/watch?v=HAtsUpBlnf8
http://www.youtube.com/watch?v=V6eHKcZkDtg
@RaVbaker
RaVbaker / readme.md
Created March 29, 2012 19:15
[HOWTO] SSH login without password

SSH login without password

Your aim

You want to use Linux and OpenSSH to automize your tasks. Therefore you need an automatic login from host A / user a to Host B / user b. You don't want to enter any passwords, because you want to call ssh from a within a shell script.

How to do it

First log in on A as user a and generate a pair of authentication keys. Do not enter a passphrase:

@RaVbaker
RaVbaker / app_proxy.rb
Last active July 20, 2020 08:55
Simple HTTP app Proxy using sinatra
# ENDPOINT="host.com" ruby app_proxy.rb
# curl -i localhost:4567/capture # => "<TIMEOUT>" or regular response every 2 calls
require 'sinatra'
require 'net/http'
$request_settings = { host: ENV["ENDPOINT"] }
$headers = { "Content-Type" => "application/json" }
$counter = 0
@RaVbaker
RaVbaker / readme.md
Last active October 23, 2019 15:27
[HOWTO] Forward ports a.k.a. make SSH Tunneling

Syntax:

ssh -L localport:host:hostport user@ssh_server -N 

where:

  • -L - port forwarding parameters (see below)
  • localport - local port (chose a port that is not in use by other service)
  • host - server that has the port (hostport) that you want to forward
  • hostport - remote port
@RaVbaker
RaVbaker / README.md
Last active February 3, 2019 18:04 — forked from mchelen/README.md
JSON Resume sample