Skip to content

Instantly share code, notes, and snippets.

View voldyman's full-sized avatar

Akshay Shekher voldyman

View GitHub Profile
@voldyman
voldyman / gist:5521828
Created May 5, 2013 19:09
podcast app demo
using Gtk;
using Soup;
using Json;
namespace Podcasts {
public class Application : Gtk.Window {
Gtk.Grid grid;
Soup.SessionAsync session;
@voldyman
voldyman / gist:5524265
Created May 6, 2013 09:50
Gerbil old code
//compile w ith valac --pkg gio-2.0 --pkg gdk-3.0 server.vala -o server && ./server
//deps: xdotool libgdk gio-2.0
int cx = 0;
int cy = 0;
Gdk.Display display = null;
Gdk.Screen screen = null;
Gdk.Device pointer = null;
@voldyman
voldyman / arrow.c
Created May 12, 2013 08:22
get ascii code for keys
// gcc -o arrow arrow.c -lcurses
#include <curses.h>
#include <stdio.h>
int main(void)
{
int ch = 0;
initscr();
cbreak();
@voldyman
voldyman / scrape.py
Created June 24, 2013 09:14
Simple python API scraper
from BeautifulSoup import BeautifulSoup
from urllib2 import urlopen
def get_page(pageToScrape):
return urlopen(pageToScrape).read()
def main():
pagesToScrape = ['http://example.com/data1/api.xml' , 'http://example.com/data2/api.xml']
@voldyman
voldyman / gist:5965810
Created July 10, 2013 12:13
colors for bash
BOLD=$(tput bold)
RESET=$(tput sgr0)
SOLAR_RED=$(tput setaf 1)
SOLAR_GREEN=$(tput setaf 2)
SOLAR_YELLOW=$(tput setaf 3)
SOLAR_BLUE=$(tput setaf 4)
SOLAR_MAGENTA=$(tput setaf 5)
SOLAR_CYAN=$(tput setaf 6)
SOLAR_WHITE=$(tput setaf 7)
SOLAR_ORANGE=$(tput setaf 4)
for fgbg in 38 48 ; do #Foreground/Background
for color in {0..256} ; do #Colors
#Display the color
echo -en "\e[${fgbg};5;${color}m ${color}\t\e[0m"
#Display 10 colors per lines
if [ $((($color + 1) % 10)) == 0 ] ; then
echo #New line
fi
done
echo #New line
// http://imgur.com/EKKMKNn
using Gtk;
class OptionBox : EventBox {
public signal void clicked ();
public OptionBox (string title, string info) {
var main_grid = new Grid ();
var title_label = new Label (null);
var info_label = new Label (info);
@voldyman
voldyman / gist:6242825
Last active December 21, 2015 03:29
quick hack to check if a program is running in a termianl
// valac --pkg vte-2.90 --pkg gtk+-3.0 test.vala
public class Wind {
GLib.Pid child_pid;
public Wind () {
var w = new Gtk.Window ();
w.set_size_request (640,480);
w.destroy.connect (Gtk.main_quit);
var ter = new Vte.Terminal ();
var dir = GLib.Environment.get_current_dir ();
ter.fork_command_full (Vte.PtyFlags.DEFAULT, dir, { Vte.get_user_shell () },
@voldyman
voldyman / ns.js
Created December 21, 2013 07:45
simple way to use namespaces in javascript
/*
jsfiddle of the following code: http://jsfiddle.net/VGA82/
*/
(function(pt, undefined) {
pt.woah = 'public property';
var woa = 'private property';
import os
import sys
import subprocess
import mimetypes
def get_mimetype(loc):
process = subprocess.Popen(['mimetype',loc], stdout=subprocess.PIPE)
output, err = process.communicate()
if err != None: