Skip to content

Instantly share code, notes, and snippets.

@sergiobuj
sergiobuj / Palindromize
Created April 5, 2010 03:32
Topcoder problem
Palidromized topcoder
string minAdds(string s) {
string res,a,b,aux;
a=s;b=s;
aux=s;
reverse(aux.begin(),aux.end());
if(s == aux)
return s;
@sergiobuj
sergiobuj / TopCoder emacs tc cc func
Created April 9, 2010 23:18
Function to compile and run g++ Topcoder problems
;; TopCoder .cc compile function. (When using .cpp change -3 -> -4 -two times-)
(defun tc () (interactive)
(compile (concat "g++ " (buffer-name)" -Wall -g -o "(substring (buffer-name) 0 -3)" && ./"(substring (buffer-name) 0 -3)))
)
@sergiobuj
sergiobuj / CC
Created April 22, 2010 03:35
Simple terminal animation in C
// Sergio Botero
// Status:
#include <cstdio>
#include <string>
int main (){
while( 1 ){
for(int i = 0; i < 25; usleep(30000), printf("%s+%s+%s\r", std::string(i++, ' ').c_str(), std::string( 50-(2*i) , ' ').c_str(), std::string(i, ' ').c_str())) fflush(stdout);
for(int i = 25; i >= 0; usleep(30000), printf("%s+%s+%s\r", std::string(i--, ' ').c_str(), std::string( 50-(2*i) , ' ').c_str(), std::string(i, ' ').c_str())) fflush(stdout);
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" \
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- Contains a unique string that identifies your daemon to launchd.
This key is required. -->
<key>Label</key>
<string>com.gocongress.backup</string>
@sergiobuj
sergiobuj / SetPoints.m
Created June 13, 2011 00:33
Working with coordinates in iOS
for (NSDictionary *dict in [samplePlist objectForKey:@"map_points"]) {
// NSLog(@"%lf %lf %@", [[dict objectForKey:@"latitude"] doubleValue], [[dict objectForKey:@"longitude"] doubleValue], [dict objectForKey:@"title"]);
CLLocationCoordinate2D coord = { [[dict objectForKey:@"latitude"] doubleValue] , [[dict objectForKey:@"longitude"] doubleValue] };
MPoint *point = [[MPoint alloc] initWithCoordinate:coord];
[point setTitle:[dict objectForKey:@"title"]];
@sergiobuj
sergiobuj / counting_sort_c.c
Created September 7, 2011 00:44
Counting sort written in C
/* @(#)counting_sort_cool.c
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
/* #include "counting_sort.h"
*/
int main(int argc, char * argv[])
@sergiobuj
sergiobuj / mask.c
Created February 7, 2012 04:28
CGEventFlag bit mask and hotkey detection
if( ((flags & kCGEventFlagMaskAlphaShift) == 0 &&
(flags & kCGEventFlagMaskShift) == 0 &&
(flags & kCGEventFlagMaskControl) == 0 &&
(flags & kCGEventFlagMaskAlternate) == 0 &&
(flags & kCGEventFlagMaskCommand) == kCGEventFlagMaskCommand &&
(flags & kCGEventFlagMaskHelp) == 0 &&
(flags & kCGEventFlagMaskSecondaryFn) == kCGEventFlagMaskSecondaryFn &&
(flags & kCGEventFlagMaskNumericPad) == kCGEventFlagMaskNumericPad &&
(flags & kCGEventFlagMaskNonCoalesced) == kCGEventFlagMaskNonCoalesced) &&
@sergiobuj
sergiobuj / apolo_admin.sh
Created March 20, 2012 22:52
Apolo admin script
#!/bin/bash
#
#
# Script name: Que belleza
# Author: Sergio Botero sbotero2[a]eafit.edu.co
#
#
## IP
readonly ips="10.10.60."
@sergiobuj
sergiobuj / fast.sh
Created April 10, 2012 02:57 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env bash
##
# Install:
# curl -sL https://raw.github.com/gist/2108403/fast.sh | sh
#
# Share your feedbacks on:
# https://gist.github.com/2108403
#
# Author: @DAddYE (Twitter/Github)
@sergiobuj
sergiobuj / petservices.json
Created May 14, 2012 01:53
Possible API description for Symptoms Checker App
///// request 1, fetch pet symptoms in http://link.to.pets/in.json
{
"petparts": [
{
"partname": "tail",
"symptoms": [
{
"id": 1,
"name": "long tail"