Skip to content

Instantly share code, notes, and snippets.

View juandesant's full-sized avatar

Juande Santander-Vela juandesant

View GitHub Profile
@gruber
gruber / make_bookmarklet.pl
Last active May 5, 2024 21:11
JavaScript Bookmarklet Builder
#!/usr/bin/env perl
#
# http://daringfireball.net/2007/03/javascript_bookmarklet_builder
use strict;
use warnings;
use URI::Escape qw(uri_escape_utf8);
use open IO => ":utf8", # UTF8 by default
":std"; # Apply to STDIN/STDOUT/STDERR
@hofmannsven
hofmannsven / README.md
Last active February 2, 2024 20:47
Raspberry Pi Cheatsheet
@jgilchrist
jgilchrist / einstein.pl
Last active December 10, 2022 20:33
A Prolog solution to Einstein's Riddle
right_of(X, Y) :- X is Y+1.
left_of(X, Y) :- right_of(Y, X).
next_to(X, Y) :- right_of(X, Y).
next_to(X, Y) :- left_of(X, Y).
solution(Street, FishOwner) :-
Street = [
house(1, Nationality1, Color1, Pet1, Drinks1, Smokes1),
house(2, Nationality2, Color2, Pet2, Drinks2, Smokes2),
@sorbits
sorbits / every
Last active February 22, 2024 03:58
Run «command» only every «number» time invoked
#!/usr/bin/env bash
progname=$(basename $0)
version="1.0 (2014-08-17)"
step=2
function create_hash {
openssl dgst -sha1 -binary <<< "$1" | xxd -p
}
@joezuntz
joezuntz / gist:4c791f9592d1798577da
Created November 14, 2014 14:12
Bayes Lecture 1 Medium Question Answer
{
"metadata": {
"kernelspec": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"display_name": "IPython (Python 2)",
"language": "python",
"name": "python2"
// AFNetworking
[[AFHTTPSessionManager manager] GET:@"http://httpbin.org/ip" parameters:nil success:^(NSURLSessionDataTask *task, id JSON) {
NSLog(@"IP Address: %@", JSON[@"origin"]);
} failure:^(NSURLSessionDataTask *task, NSError *error) {
NSLog(@"Error: %@", error);
}];
// NSURLSession
NSURL *URL = [NSURL URLWithString:@"http://httpbin.org/ip"];
@kenkeiter
kenkeiter / impbcopy.m
Last active January 17, 2024 23:02
Take a selfie, archive it, and copy it to the clipboard -- all from the terminal! (bash + os x)
/////////////////////////////////////////////////////////
// Copied from http://www.alecjacobson.com/weblog/?p=3816
/////////////////////////////////////////////////////////
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import <unistd.h>
BOOL copy_to_clipboard(NSString *path)
{
// http://stackoverflow.com/questions/2681630/how-to-read-png-image-to-nsimage
NSImage * image;
@beng
beng / impbcopy.m
Last active September 4, 2018 07:03 — forked from kenkeiter/impbcopy.m
/////////////////////////////////////////////////////////
// Copied from http://www.alecjacobson.com/weblog/?p=3816
/////////////////////////////////////////////////////////
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import <unistd.h>
BOOL copy_to_clipboard(NSString *path)
{
// http://stackoverflow.com/questions/2681630/how-to-read-png-image-to-nsimage
NSImage * image;
#!/usr/bin/perl
# This filter changes all words to Title Caps, and attempts to be clever
# about *un*capitalizing small words like a/an/the in the input.
#
# The list of "small words" which are not capped comes from
# the New York Times Manual of Style, plus 'vs' and 'v'.
#
# 10 May 2008
# Original version by John Gruber:
@skreutzberger
skreutzberger / getICloudUserID.swift
Last active August 31, 2018 04:13
get iCloud User ID
import CloudKit
/// async gets iCloud record ID object of logged-in iCloud user
func iCloudUserIDAsync(complete: (instance: CKRecordID?, error: NSError?) -> ()) {
let container = CKContainer.defaultContainer()
container.fetchUserRecordIDWithCompletionHandler() {
recordID, error in
if error != nil {
print(error!.localizedDescription)
complete(instance: nil, error: error)