Skip to content

Instantly share code, notes, and snippets.

View sahib's full-sized avatar
🤘

Chris Pahl sahib

🤘
View GitHub Profile
@sahib
sahib / glyr_opt_dlcallback.rb
Created September 20, 2011 13:22
glyr_opt_dlcallback
require './glyros.so'
q = Glyros::GlyrQuery.new
Glyros::glyr_query_init(q)
Glyros::glyr_opt_artist(q,"Equilibrium")
Glyros::glyr_opt_type(q,Glyros::GLYR_GET_ARTIST_PHOTOS)
Glyros::glyr_opt_number(q,5)
my_proc = Proc.new do |cache,query|
Glyros::glyr_cache_print cache
require './glyros.so'
include Glyros
# Brief example on how to use glyr_db_foreach() and the require macros
# Sorry if this looks like Ruby. It's acutally ruby-flavoured C :-)
# A filled DB is required, read to use example:
# $ glyrc artistphotos -a "Bring me the horizon" -n 10 -c /tmp
# Gets the 'requirements' for a certain fetcher by it's type
require './glyros.so'
include Glyros
# Simple example on how to directly call a certain
# provider's get_url() and parser() function.
# We need a query (as usual)
q = GlyrQuery.new
glyr_query_init(q)
glyr_opt_artist(q,"Equilibrium")
require './glyros.so'
include Glyros
# Simple example on how to use glyr_info_get
# and the require macros appear here too.
def req_to_string reqs, required, optional
return "required" if (reqs & required) != 0
return "optional" if (reqs & optional) != 0
return "not needed"
// Übungsbeispiel Stöhr
// man sollte erst versuchen es selbst zu lösen und dann das hier zu lösen.
// (Ich bin mir nicht sicher was schwerer ist :-))
// Sind vermutlich ein paar Fehler drin - einfach unten posten.
// (Anmerkung: Die Kommentare sind nicht von Prof. Stöhr)
#include <stdio.h>
/* Ein Array aus Strings */
char *c[] = {"ENTER", "NEW", "POINT", "FIRST"};
// Kurzes Beispiel wie man die Member einer Template Klasse
// doch noch auslagern kann - vor Gebrauch in Datein aufsplitten :-)
// Kompilieren mit: g++ template_main.cc template.cc template.hh -Wall -Wextra
//
// Das ganze ist etwas unschön. Was lernen wir daraus?
// Das gleiche wie bei 'new' templates nur benutzen wenn's
// wirklich begründet ist.
// ~c3
//===================================
#include <glib.h>
#include <stdlib.h>
#include <string.h>
static void foreach_file(const gchar * song_dir_path, const gchar * regex);
static gboolean path_go_up(char * song_dir_path);
static void find_in_musictree(const gchar * song_file_path, const gchar * regex, gint up_to);
//---------------------------------------------------
require 'find'
require 'tempfile'
$license = <<-eos
/* Cats insert there license here
* Hmm. Replace this.
*/
eos
# Insert license at beginning, using a crappy tmp file.
def randomize str
out = ""
pos = (0..str.length-1).to_a
pos.each do |num|
new_pos = rand(str.length-1)
# Swap
tmp = pos[num]
pos[num] = pos[new_pos]
import java.lang.Math;
import java.util.Arrays;
class A3 extends Thread {
private static final int N = 3;
private int myid = 0;
public volatile static Integer array[] = {0,0,0};
A3(int i)