Skip to content

Instantly share code, notes, and snippets.

View sandeepone's full-sized avatar
💭
I may be slow to respond.

Sandeep Sangamreddi sandeepone

💭
I may be slow to respond.
View GitHub Profile
@sandeepone
sandeepone / word_wrap.go
Created November 18, 2019 08:52 — forked from kennwhite/word_wrap.go
Basic golang word wrap string split
/*
Wrap long lines on rough column boundaries at spaces
Working example: https://play.golang.org/p/3u0X6NyMua
Based on algo from RosettaCode, which is nifty
https://www.rosettacode.org/wiki/Word_wrap#Go
*/
package main
import (
@sandeepone
sandeepone / main.go
Created November 11, 2019 00:47 — forked from pyanfield/main.go
query mysql db with golang
package main
import (
"database/sql"
"fmt"
"runtime"
"strconv"
"time"
_ "github.com/go-sql-driver/mysql"
Googlebot/2.1 (+http://www.google.com/bot.html) # Pattern: Googlebot\/ / URL: http://www.google.com/bot.html
Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) # Pattern: Googlebot\/ / URL: http://www.google.com/bot.html
Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) # Pattern: Googlebot\/ / URL: http://www.google.com/bot.html
Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/537.36 (KHTML, like Gecko) Version/8.0 Mobile/12F70 Safari/600.1.4 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) # Pattern: Googlebot\/ / URL: http://www.google.com/bot.html
Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12F70 Safari/600.1.4 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) # Pattern: Googlebot\/ / URL: http://www.google.com/bot.html
Mozilla
@sandeepone
sandeepone / relayStore.js
Created June 24, 2019 03:50 — forked from ro-savage/relayStore.js
Implement a cache and fetch with relay
// This code is untested. It may new some minor modifications to work
import RelayQueryResponseCache from "relay-runtime/lib/RelayQueryResponseCache";
import {
Environment,
Network,
RecordSource,
Store,
Observable
@sandeepone
sandeepone / asymmetric.go
Created February 11, 2019 10:02 — forked from cryptix/LICENSE
example of using JWT for http authentication in go
package main
// using asymmetric crypto/RSA keys
import (
"crypto/rsa"
"fmt"
"io/ioutil"
"log"
"net/http"
@sandeepone
sandeepone / 1_GraphQL.md
Created December 8, 2017 17:03 — forked from paralin/1_GraphQL.md
GraphQL @defer, @LiVe, @stream implementation notes

Notes moved from graph-gophers/graphql-go#15

Graphql-js can parse directives like @live just fine -

parsed.definitions[0].selectionSet.selections[0].selectionSet.selections[0].directives[0] =
{ kind: 'Directive',
  name: { kind: 'Name', value: 'live', loc: { start: 26, end: 30 } },
  arguments: [],
 loc: { start: 25, end: 30 } }
@sandeepone
sandeepone / final
Created November 25, 2017 19:46 — forked from mlimaloureiro/final
.
├──delivery // Serve content via HTTP? CLI? everything related to that should be here
| └── http
| ├── app.go // where we have our GIN app
| ├── app_test.go // our app tests
| ├── context // some gin dependencies
| | ├── context.go
| │ └── mocks
| │ └── Context.go
| ├── controllers // our controllers
package main
import (
"fmt"
"reflect"
)
//function types
type mapf func(interface{}) interface{}
@sandeepone
sandeepone / interface.go
Created October 13, 2017 19:38 — forked from icambridge/interface.go
Observer pattern - golang
type TestCallBack struct {
}
func (c *TestCallBack) Exec(o *Observable) {
log.Println(o.Name)
}
type Callback interface {
Exec(h *Observable)
@sandeepone
sandeepone / pre-commit
Last active July 11, 2017 11:37
PHP-CS-Fixer Git pre-commit hook
#!/usr/bin/env bash
## Install
# $ wget https://gist.github.com/sandeepone/1c43a96be98e0a864535f59252668b5b/raw/pre-commit -O .git/hooks/pre-commit
# $ chmod +x .git/hooks/pre-commit
#
# Please install php-cs-fixer
# composer require --dev fabpot/php-cs-fixer:dev-master
EXECUTABLE_NAME=php-cs-fixer