Skip to content

Instantly share code, notes, and snippets.

View voldyman's full-sized avatar

Akshay Shekher voldyman

View GitHub Profile
@voldyman
voldyman / stars-with-spacing.c
Created October 30, 2014 17:04
print stars with spacing
#include<stdio.h>
void print_char(char c, int num)
{
if (num <= 0)
return;
printf("%c", c);
print_char(c, --num);
@voldyman
voldyman / start-correct.c
Created October 30, 2014 16:57
print stars recursively
#include<stdio.h>
void print_char(char c, int num)
{
if (num < 0)
return;
printf("%c", c);
print_char(c, --num);
}
@voldyman
voldyman / stars.c
Created October 30, 2014 16:54
print rows of stars recursively
#include<stdio.h>
void print_char(char c, int num)
{
if (num < 0)
return;
printf("%c", c);
print_char(c, --num);
@voldyman
voldyman / keycapture.vala
Last active August 29, 2015 14:07
code to for global hot keys
void main(string[] args) {
Gtk.init (ref args);
Gdk.Window win = Gdk.get_default_root_window ();
win.add_filter(null, filter_func);
unowned X.Display display = Gdk.X11.get_default_xdisplay ();
display.grab_key (display.keysym_to_keycode('C'),
@voldyman
voldyman / CellRenderer-treeview.vala
Last active October 17, 2021 18:56
This file shows how to use a custom cell renderer in a Gtk Treeview to build complex layouts
class MyCellRenderer : Gtk.CellRenderer {
// icon property set by the tree column
public Gdk.Pixbuf icon { get; set; }
public string text { get; set; }
public int progress { get; set; }
public int Padding;
private Gtk.CellRendererPixbuf icon_renderer;
private Gtk.CellRendererText text_renderer;
@voldyman
voldyman / Iter.go
Created July 9, 2014 12:29
The Golang's range operator is limited to a few times, this example allows you to iterate over custom collections
package main
import "fmt"
type Container struct {
values []int
}
func (this *Container) Iter() <- chan int {
ch := make(chan int)
@voldyman
voldyman / DataTime.go
Created July 9, 2014 12:27
The launchpad API provides date in a weird format, this code parses that date-time
package main
import (
"fmt"
"time"
"reflect"
)
func main() {
test, err := time.Parse( "2006-01-02T15:04:5-07:00", "2014-06-02T16:26:28.514048+00:00")
package main
import (
"encoding/json"
"net/http"
"net/url"
"io"
"io/ioutil"
"os"
)
@voldyman
voldyman / dnd.vala
Created April 29, 2014 10:37
Gtk accept drag drop, simple example
/*
Written by Akshay Shekher
to show how to use drag and drop in Gtk cleanly.
*/
int main(string[] args) {
Gtk.init (ref args);
@voldyman
voldyman / gist:11348397
Created April 27, 2014 15:24
what modules in js should be like
<body>
<script src="classes2.js"></script>
<script>
tri.module(
'pentagine.core'
).defines(function() {
this.price = 10;
this.getData = function() {
return this.price;
}