Skip to content

Instantly share code, notes, and snippets.

@FurryHead
FurryHead / perlab.pl
Created July 31, 2011 20:57
TinyCore Linux appbrowser written in perl, can be run from OSs other than TinyCore.
#!/usr/bin/perl -w
use warnings;
use strict;
use Term::ReadKey;
my $tce_mirror = "http://distro.ibiblio.org/pub/linux/distributions/tinycorelinux/";
my $tce_dir = `cat /opt/.tce_dir`;
$tce_dir = "./tce" if ($tce_dir eq "");
chomp $tce_dir;
@FurryHead
FurryHead / pmakegen.pl
Created July 31, 2011 03:24
Makefile generator in Perl
#!/usr/bin/perl -w
use strict;
use Getopt::Std;
########The script defaults#########
my $make_outfile = "PerlMakefile";
my $exe_outfile = "p.out";
my $compiler = "gcc";
my $src_dir = "./src";
my $obj_dir = "./obj";
@FurryHead
FurryHead / array.h
Created July 15, 2011 19:00
Dynamic array and map in C (header).
#ifndef ARRAY_H
#define ARRAY_H
#ifdef __cplusplus
extern "C" {
#endif
#define ARRAY_EXPAND_SIZE 10
struct array {
@FurryHead
FurryHead / array.c
Created July 15, 2011 18:55
Dynamic array and map in C.
#include <string.h>
#include <stdlib.h>
#include "array.h"
typedef struct array array;
typedef struct map map;
/** @brief Allocates and initializes a new array */
array *array_new(void) {
array *tmp = malloc(sizeof(array));
@FurryHead
FurryHead / string_sj_main.c
Created July 13, 2011 20:43
C split/join functions, using strtok_r -- Main test
#include <stdio.h>
#include <stdlib.h>
#include "string_sj.h"
int main(int argc, char** argv) {
char **items = NULL;
const char *s = "Hello, I'm splitting on the space delimiter!";
const char *delim = " ";
char *tmp;
int i;
@FurryHead
FurryHead / string_sj.h
Created July 13, 2011 20:41
C split/join functions, using strtok_r -- Header
#ifndef SPLIT_JOIN_H
#define SPLIT_JOIN_H
#ifdef __cplusplus
extern "C" {
#endif
int str_split(const char *src, const char* delim, char*** dest);
char *str_join(char** items, int num_items, const char* delim);
@FurryHead
FurryHead / string_sj.c
Created July 13, 2011 20:21
C split/join functions, using strtok_r -- Source
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "string_sj.h"
int str_split(const char* src, const char* delims, char*** dest) {
char *s = strdup(src);
char *c, *saveptr, *tmp;
void *_tmp;
int num_tokens = 0, num_size = 10;
function handle_319(source, argms)
local user = ""
local reading_channels = false
for argm in argms:gmatch("%a+") do
if argm:match("^%:.+$") then
reading_channels = true
argm = argm:sub(2)
end
-------------------------------------------------------------
if reading_channels then
void PluginManager::fire(string event, int numargs, ...) {
lua_getglobal(L, "plugins");
int table_index = lua_gettop(L);
if(!lua_istable(L, table_index)) {
lua_pop(L, 1);
lua_newtable(L);
lua_setglobal(L, "plugins");
return;
}
lua_pushnil(L);
string[3] user;
// this end up in the sequence [0] = nick, [1] = ident, [2] = host
user[0] = split(trim(words[0], ":"), "!")[0];
if (words[0].find("!") != string::npos && words[0].find("@") != string::npos) {
user[1] = split(split(trim(words[0], ":"), "!")[1], "@")[0];
user[2] = split(split(trim(words[0], ":"), "!")[1], "@")[1];
} else {
user[1] = "";
user[2] = "";
}