Skip to content

Instantly share code, notes, and snippets.

trait Generator[+T] {
self =>
def generate: T
def map[S](f: T => S): Generator[S] = new Generator[S] {
def generate = f.apply(self.generate)
}
@InsertNetan
InsertNetan / NSURL+Query.swift
Last active April 21, 2017 09:34
get the value of a specific query item within NSURL
extension NSURL {
func getQueryItemValueForKey(key: String) -> String? {
guard let components = NSURLComponents(URL: self, resolvingAgainstBaseURL: false) else {
return nil
}
guard let queryItems = components.queryItems else { return nil }
return queryItems.filter {
$0.name == key
}.first?.value
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@edgar
edgar / pre-commit
Last active November 24, 2022 13:42 — forked from FerPerales/pre-commit.sh
Git: Pre-commit git hook that prevents commits with undesired words, usually debugging statements #git #hook #pre-commit
# This script verifies if a list of "undesired" words are presented in the files you are intended to commit such console
# output, debugging information or keys/tokens/passwords
# Based on the git hook created by Mark Story
# http://mark-story.com/posts/view/using-git-commit-hooks-to-prevent-stupid-mistakes
# Instructions:
# Put this file into your .git/hooks folder and set as executable (chmod +x pre-commit)
@alexjs
alexjs / cors-nginx.conf
Created November 28, 2012 22:42 — forked from michiel/cors-nginx.conf
Slightly tighter CORS config for nginx
#
# Slightly tighter CORS config for nginx
#
# A modification of https://gist.github.com/1064640/ to include a white-list of URLs
#
# Despite the W3C guidance suggesting that a list of origins can be passed as part of
# Access-Control-Allow-Origin headers, several browsers (well, at least Firefox)
# don't seem to play nicely with this.
#
@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

@nucliweb
nucliweb / js-terms.md
Created January 24, 2016 09:13 — forked from AllThingsSmitty/js-terms.md
10 terms to help you better understand JavaScript

10 JavaScript Terms You Should Know

From currying to closures there are quite a number of special words used in JavaScript. These will not only help you increase your vocabulary but also better understand JavaScript. Special terms are normally found in documentation and technical articles. But some of them like closures are pretty standard things to know about. Knowing what the word itself means can help you know the concept it's named for better.

  1. Arity
  2. Anonymous
  3. Closure
  4. Currying
  5. Hoisting
  6. Mutation
@alex-cellcity
alex-cellcity / Version.m
Created May 30, 2011 04:55
Runtime iOS Version Checking
/*
* System Versioning Preprocessor Macros
*/
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
@zach-klippenstein
zach-klippenstein / ChangePassword.java
Last active April 3, 2024 18:04
The keystore password on Java keystore files is utterly pointless. You can reset it without knowing it, as shown by this code. Note that private keys are still secure, as far as I know. The JKS implementation is copyright Casey Marshall (rsdio@metastatic.org), and the original source is available at http://metastatic.org/source/JKS.java. I've in…
import java.util.*;
import java.io.*;
import java.security.*;
public class ChangePassword
{
private final static JKS j = new JKS();
public static void main(String[] args) throws Exception
{
@yufengg
yufengg / AutoML_data_preparation_AIA023.ipynb
Last active April 15, 2024 13:30
Notebook for preparing a CSV for Google Cloud AutoML Vision
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.