Skip to content

Instantly share code, notes, and snippets.

View chrisjmendez's full-sized avatar
🎯
Focusing

Chris Mendez chrisjmendez

🎯
Focusing
View GitHub Profile
@blainerothrock
blainerothrock / gen.swift
Last active July 12, 2018 15:56
A Very Simple Genetic Algorithm Written in Swift 3
#!/usr/bin/env xcrun swift -O
/*
gen.swift is a direct port of cfdrake's helloevolve.py from Python 2.7 to Swift 3
-------------------- https://gist.github.com/cfdrake/973505 ---------------------
gen.swift implements a genetic algorithm that starts with a base
population of randomly generated strings, iterates over a certain number of
generations while implementing 'natural selection', and prints out the most fit
string.
The parameters of the simulation can be changed by modifying one of the many
@montanaflynn
montanaflynn / CONCURRENCY.md
Last active April 20, 2024 17:00
Examples of sequential, concurrent and parallel requests in node.js

Concurrency in JavaScript

Javascript is a programming language with a peculiar twist. Its event driven model means that nothing blocks and everything runs concurrently. This is not to be confused with the same type of concurrency as running in parallel on multiple cores. Javascript is single threaded so each program runs on a single core yet every line of code executes without waiting for anything to return. This sounds weird but it's true. If you want to have any type of sequential ordering you can use events, callbacks, or as of late promises.

@justinpawela
justinpawela / config
Created August 3, 2016 01:39
AWS CodeCommit Multiple Account Config
# This file is: ~/.ssh/config
# You may have other (non-CodeCommit) SSH credentials stored in this
# config file – in addition to the CodeCommit settings shown below.
# NOTE: Make sure to run [ chmod 600 ~/.ssh/config ] after creating this file!
# Credentials for Account1
Host awscc-account1 # 'awscc-account1' is a name you pick
Hostname git-codecommit.us-east-1.amazonaws.com # This points to CodeCommit in the 'US East' region
@dannguyen
dannguyen / README.md
Last active December 28, 2023 15:21
Using Python 3.x and Google Cloud Vision API to OCR scanned documents to extract structured data

Using Python 3 + Google Cloud Vision API's OCR to extract text from photos and scanned documents

Just a quickie test in Python 3 (using Requests) to see if Google Cloud Vision can be used to effectively OCR a scanned data table and preserve its structure, in the way that products such as ABBYY FineReader can OCR an image and provide Excel-ready output.

The short answer: No. While Cloud Vision provides bounding polygon coordinates in its output, it doesn't provide it at the word or region level, which would be needed to then calculate the data delimiters.

On the other hand, the OCR quality is pretty good, if you just need to identify text anywhere in an image, without regards to its physical coordinates. I've included two examples:

####### 1. A low-resolution photo of road signs

@chrisjmendez
chrisjmendez / StreamURI.md
Last active August 27, 2021 15:24
Triton Audio streams for Classical KUSC and Classical KDFC

Stream URL's for Classical KUSC and Classical KDFC

New URL Pattern:

http://[bit rate].[encoder format].[file format].[call letters].live

Old URL Pattern:

@kristopherjohnson
kristopherjohnson / utcDateTime.m
Last active December 8, 2017 12:31
Get UTC date/time string for current time using NSCalendar
NSDate *date = [NSDate date];
NSCalendar *utcCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
utcCalendar.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
unsigned ymdhmsUnitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay| NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
NSDateComponents *utcDateComponents = [utcCalendar components:ymdhmsUnitFlags fromDate:date];
// Create string of form "yyyy-mm-dd hh:mm:ss"
@calebd
calebd / AsynchronousOperation.swift
Last active April 29, 2023 13:12
Concurrent NSOperation in Swift
import Foundation
/// An abstract class that makes building simple asynchronous operations easy.
/// Subclasses must implement `execute()` to perform any work and call
/// `finish()` when they are done. All `NSOperation` work will be handled
/// automatically.
open class AsynchronousOperation: Operation {
// MARK: - Properties
// Photoshop Script to Create iPhone Icons from iTunesArtwork // // WARNING!!! In the rare case that there are name collisions, this script will // overwrite (delete perminently) files in the same folder in which the selected // iTunesArtwork file is located. Therefore, to be safe, before running the // script, it's best to make sure the selected iTuensArtwork file is the only // file in its containing folder. // // Copyright (c) 2010 Matt Di Pasquale // Added tweaks Copyright (c) 2012 by Josh Jones http://www.appsbynight.com // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and
@gleitz
gleitz / MIDI_scales.js
Last active February 11, 2024 06:17
MIDI scale arrays in Javascript
var scales = {
'natural major': [0,2,4,5,7,9,11,12],
'ionian': [0,2,4,5,7,9,11,12],
'major': [0,2,4,5,7,9,11,12],
'chromatic': [0,1,2,3,4,5,6,7,8,9,10,11,12],
'spanish 8 tone': [0,1,3,4,5,6,8,10,12],
'flamenco': [0,1,3,4,5,7,8,10,12],
'symmetrical': [0,1,3,4,6,7,9,10,12],
'inverted diminished': [0,1,3,4,6,7,9,10,12],
'diminished': [0,2,3,5,6,8,9,11,12],
@iggym
iggym / gist:6023041
Last active April 28, 2023 23:35
Apple iTunes Search API and RSS feeds. --- Apple very usefully provides unauthenticated json feeds for both the iTunes search and iTunes rss
Apple very usefully provides unauthenticated json feeds for both the iTunes search and iTunes rss
The Search API returns your search results in JavaScript Object Notation (JSON) format. JSON is built on two structures:
All JSON results are encoded as UTF-8. For more information on JSON, please see http://www.json.org.
---
Search API
http://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html
---
RSS Info