Skip to content

Instantly share code, notes, and snippets.

View ziyadparekh's full-sized avatar

Ziyad Parekh ziyadparekh

View GitHub Profile
@navono
navono / reconn.go
Created July 23, 2019 07:09
websocket reconnect in golang
package reconWS
import (
"errors"
"math/rand"
"net/http"
"net/url"
"sync"
"time"
@paragtokopedia
paragtokopedia / query_builder.go
Last active January 6, 2024 18:37
Query Builder
package query_builder
import (
"strings"
"strconv"
"html/template"
"fmt"
)
type DynamicQueryBuilder string
@swalkinshaw
swalkinshaw / tutorial.md
Last active November 13, 2023 08:40
Designing a GraphQL API
@vlucas
vlucas / encryption.js
Last active March 18, 2024 13:49
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);
@kiyoto
kiyoto / collatz.markdown
Created May 1, 2016 09:10
The Collatz Conjecture in PostgreSQL

##QUERY (PostgreSQL 9.4)

WITH RECURSIVE t(n) AS (
  VALUES(1337)
  UNION ALL
  SELECT CASE WHEN n%2=0 THEN n/2 ELSE 3*n+1 END FROM t WHERE n > 1)
SELECT * FROM t
@HarryGoodwin
HarryGoodwin / gist:4528d6419915258e54b2f8c804687808
Last active August 10, 2023 02:28
Attributed string bullet points - Swift
import UIKit
import PlaygroundSupport
struct StringConstants {
static let bullet1 = "This is a small string."
static let bullet2 = "This is more of medium string with a few more words etc."
static let bullet3 = "Well this is certainly a longer string, with many more words than either of the previuos two strings."
}
typealias ParagraphData = (bullet: String, paragraph: String)
@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

@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
const React = require('react-native');
const FBSDKCore = require('react-native-fbsdkcore');
const FBSDKLogin = require('react-native-fbsdklogin');

Search for functions via expected imput / output

I have a programming need. I need a function that most-likley exists already. Someone has made it and it's probably public. If it doesn't exist theres probably some combination of functions out there that exist that can make it happen.

Here's a string input and output.

'focus together' > 'focus_together'
'focusTogether' > 'focus_together'
'focus Together' > 'focus_together'