Skip to content

Instantly share code, notes, and snippets.

View piotrmacha's full-sized avatar
💻

Piotr Macha piotrmacha

💻
View GitHub Profile
@piotrmacha
piotrmacha / gist:9841343
Created March 28, 2014 19:38
blockchain - getting info 'bout bitcoin balance + currency converter
<?php
// your blockchain guid
$guid = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
// your password
$password = 'xxxxxxxx';
// your adrresses as array
$addresses = array(
'xxxxxxxxxxxx'
);
@piotrmacha
piotrmacha / bot.rb
Created September 9, 2015 17:07
IRC bot which shows titles of URLs sent by other users.
require 'uri'
require 'cinch'
require 'open-uri'
bot = Cinch::Bot.new do
configure do |c|
c.server = "irc.freenode.org"
c.channels = ["#thelleo", '#load.re']
c.nicks = ['medyk-titlebot']
end
@piotrmacha
piotrmacha / robot.js
Created December 4, 2012 15:13
Rabitank
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(100);
@piotrmacha
piotrmacha / gist:5650939
Last active December 17, 2015 18:09
Ruby script to check online status of chat and restart it. Written for World of Equestria. It should be run from crontab.
require 'net/http'
require 'uri'
config = {
:address => 'http://web1.worldofequestria.pl:6677',
:command => 'screen -X -S chat kill; screen -dmS chat node ~/chat-server/server.js'
}
def online?(address)
begin
# encoding: utf-8
require 'faye'
require 'json'
require 'digest/md5'
config = {
:port => 9999
}
MESSAGES = {
@piotrmacha
piotrmacha / gist:6424982
Created September 3, 2013 14:53
This little snippet gets number of likes at Facebook fanpage and puts it into HTML, titlebar and console.
<h1>Loading</h1>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
var fanpage = 'worldofequestria'; //@TODO: Replace fanpage name!
setInterval(function(fp){
$.getJSON('http://graph.facebook.com/'+fp+'?callback=?', function(data){
var likes = parseInt(data.likes);
console.log('updated: ' + likes);
$('h1').html(likes);
document.title = likes + ' likes';
<?php
include('_database.php');
list($app, $uid, $token) = $argv;
$db->exec('SET NAMES utf8');
$query = $db->prepare('SELECT id, username, ponyname, guild_id, role, avatar, sex, token, banned FROM users WHERE id = :id');
$query->bindParam(':id', $uid, PDO::PARAM_INT);
$query->execute();
$user = $query->fetch(PDO::FETCH_ASSOC);
@piotrmacha
piotrmacha / WoE Ripper
Created November 29, 2013 00:36
I'm lazy... and you know what happens when programmer is lazy? He creates scripts, that will do his work! I had to download all images (except emoticons) from one topic (in MyBB based forum). So here's simple script for that. Have fun.
require 'nokogiri'
require 'open-uri'
# This function is beautiful in its simplicity
def progress(precent, current, max)
print "\r" # I don't know how it will work on Windows xD I'm running this script on Linux.
print 'Progress: %s/%s (%s%%)' % [current, max, precent.round(2)]
end
pages = 5 # You have to specify pages number manual, sorry
@piotrmacha
piotrmacha / Dane
Created December 2, 2013 19:12
Dla Aszli
<?php
/**
* Export to PHP Array plugin for PHPMyAdmin
* @version 0.2b
*/
//
// Database `humanitee-www_bash`
//
@piotrmacha
piotrmacha / RedmineNotificator
Created December 14, 2013 13:20
Simple ruby script, that will notify you about all changes in Redmine. It uses standard Redmine's RSS feed and currently works only in Ubuntu (or any other system that has got notify-osb).
require 'rss'
require 'open-uri'
$config = {
:url => '{{ REPLACE WITH YOUR REDMINE RSS FEED! }}',
:interval => 10
}
$cache = []
def loadRSS()