Skip to content

Instantly share code, notes, and snippets.

Writing if statements. Then, else.

Clemente Cuevas cuevasclemente

Writing if statements. Then, else.
  • Erudite AI
  • Montreal, QC
View GitHub Profile
cuevasclemente /
Last active Aug 29, 2015
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 / eazyE.go
Created Jan 19, 2015
eazyE: A pattern I use a lot in Go.
View eazyE.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 (
func New(s string, err error) (fErr error) {
cuevasclemente / regexps.jl
Last active Aug 29, 2015
Some of my favorite regexps, with explanations when I can remember them. Not all actually in proper Julia form necessarily
View regexps.jl
search(r"(?<=\().*?(?=\))", title)
search("(?=, ).*(?<=(is:))",locationstring)
View weather.c
#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 / weather.lisp
Created May 7, 2015
Weather App in Clisp
View weather.lisp
(require :drakma)
(require :cl-ppcre)
(defvar *weather-url* ""
"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))
View weather.nim
import httpclient
import strutils
import re
var resp = get(url = "")
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 / customjson.go
Created May 14, 2015
Custom JSON Unmarshaller
View customjson.go
package main
import (
type myStruct struct {
Field1 string
Field2 string
View vimrc.vim
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 / getcompanies.sparql
Created Sep 18, 2015
Get all yago Company108058098 companies from dbpedia
View getcompanies.sparql
PREFIX dbpedia-owl: <>
PREFIX dbpprop: <>
PREFIX dbres: <>
?x a yago:Company108058098.
limit 100
cuevasclemente /
Last active Nov 3, 2015
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