Skip to content

Instantly share code, notes, and snippets.

View cuevasclemente's full-sized avatar
💭
Writing if statements. Then, else.

Clemente Cuevas cuevasclemente

💭
Writing if statements. Then, else.
  • Erudite AI
  • Montreal, QC
View GitHub Profile
@cuevasclemente
cuevasclemente / Reverse.rs
Last active August 29, 2015 14:08
Simple reverse words commandline program
use std::io;
fn main() {
// Readline, make sure that the line is not bad, raise error otherwise
let input = io::stdin().read_line().ok().expect("Failed to read line");
// Take the input as a string slice, rather than a String
let input_slice: &str = input.as_slice(); 4
// Get words in a vector, call reverse on it, returning an iterator,
@cuevasclemente
cuevasclemente / eazyE.go
Created January 19, 2015 18:47
eazyE: A pattern I use a lot in Go.
// eazyE is a simple syrup for error checking. It is a pattern I use often enough,
// so I decided to make a quick library out of it.
package eazyE
import (
"fmt"
"log"
)
func New(s string, err error) (fErr error) {
@cuevasclemente
cuevasclemente / regexps.jl
Last active August 29, 2015 14:15
Some of my favorite regexps, with explanations when I can remember them. Not all actually in proper Julia form necessarily
replace(searchstring,r"\w(?=\?)|(\w)$",'?'))
search(r"(?<=\().*?(?=\))", title)
search("(?=, ).*(?<=(is:))",locationstring)
match(Regex("(\\w*.?\\s){$numofwords}"),title)
@cuevasclemente
cuevasclemente / weather.c
Created February 20, 2015 17:06
Weather App
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#include <stdio.h>
typedef struct response182008 response182008;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct stringtableobj145012 stringtableobj145012;
@cuevasclemente
cuevasclemente / weather.lisp
Created May 7, 2015 17:04
Weather App in Clisp
(require :drakma)
(require :cl-ppcre)
(defvar *weather-url* "http://forecast.weather.gov/MapClick.php?zoneid=NYZ075&TextType=1"
"The url we'll be going to, to get the weather information")
(defun starts-with (regexp string)
"Checks to see if a string starts
with the given regexp"
(eq (search regexp string) 0))
@cuevasclemente
cuevasclemente / weather.nim
Created May 7, 2015 17:05
Weather App in Nim
import httpclient
import strutils
import re
var resp = get(url = "http://forecast.weather.gov/MapClick.php?zoneid=NYZ075&TextType=1")
var text = resp.body
for line in splitlines(text):
if line[0..2] == "<b>" or line[0..7] == "</table>":
echo(line.replace(re"\<.*?>"), "\n")
@cuevasclemente
cuevasclemente / customjson.go
Created May 14, 2015 15:36
Custom JSON Unmarshaller
package main
import (
"encoding/json"
"fmt"
)
type myStruct struct {
Field1 string
Field2 string
set nocompatible " be iMproved, required
filetype off " required
set shell=/bin/bash
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
set incsearch
"set list
"set listchars=tab:>.
@cuevasclemente
cuevasclemente / getcompanies.sparql
Created September 18, 2015 20:21
Get all yago Company108058098 companies from dbpedia
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX dbpprop: <http://dbpedia.org/property/>
PREFIX dbres: <http://dbpedia.org/resource/>
SELECT ?x WHERE {
?x a yago:Company108058098.
}
limit 100
@cuevasclemente
cuevasclemente / execute_and_log_all.sh
Last active November 3, 2015 20:19
A cool map style paradigm to use in the shell for parallel execution and logging
# This shows a bit of shell muscle power
# First, we call find with maxdepth 1. This will make it so that find
# only searches within this current directory
# Then we use -type f to make sure find is only getting files
# then we use \! -name 'config.json'.
# Together, these flags mean that we will get only
# files (not directories, etc.) that are not named `config.json`
# in this directory.
# Thanks to Ike Levy for helping me figure out this badassery