Skip to content

Instantly share code, notes, and snippets.

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 Nov 18, 2019 — forked from kennwhite/word_wrap.go
Basic golang word wrap string split
View word_wrap.go
/*
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 Nov 11, 2019 — forked from pyanfield/main.go
query mysql db with golang
View main.go
package main
import (
"database/sql"
"fmt"
"runtime"
"strconv"
"time"
_ "github.com/go-sql-driver/mysql"
View crawler-user-agent-strings-with-descriptions.txt
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 Jun 24, 2019 — forked from ro-savage/relayStore.js
Implement a cache and fetch with relay
View relayStore.js
// 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 Feb 11, 2019 — forked from cryptix/asymmetric.go
example of using JWT for http authentication in go
View asymmetric.go
package main
// using asymmetric crypto/RSA keys
import (
"crypto/rsa"
"fmt"
"io/ioutil"
"log"
"net/http"
@sandeepone
sandeepone / 1_GraphQL.md
Created Dec 8, 2017 — forked from paralin/1_GraphQL.md
GraphQL @defer, @LiVe, @stream implementation notes
View 1_GraphQL.md

Notes moved from https://github.com/neelance/graphql-go/issues/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 } }
View 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
View hi_reddit.go
package main
import (
"fmt"
"reflect"
)
//function types
type mapf func(interface{}) interface{}
@sandeepone
sandeepone / interface.go
Created Oct 13, 2017 — forked from icambridge/interface.go
Observer pattern - golang
View interface.go
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 Jul 11, 2017
PHP-CS-Fixer Git pre-commit hook
View pre-commit
#!/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