Skip to content

Instantly share code, notes, and snippets.

View nbari's full-sized avatar
🪴

nbari

🪴
View GitHub Profile
@nbari
nbari / pr.md
Created June 5, 2016 17:19 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

/* ivan(a.t)mysqlab.net */
package main
import (
"syscall"
"os"
"log"
)
func daemon(nochdir, noclose int) int {
@nbari
nbari / gist:386af0fa667ae03daf3fbc80e3838ab0
Created July 2, 2016 07:56 — forked from juanqui/gist:7564275
Golang Kqueue Snippet
// helpful links:
// https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/EV_SET.2.html
// http://julipedia.meroh.net/2004/10/example-of-kqueue.html
// create kqueue
kq, err := syscall.Kqueue()
if err != nil {
log.Println("Error creating Kqueue descriptor!")
return
}
@nbari
nbari / scraper.py
Created October 27, 2016 19:36
web scraper
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome()
driver.get("https://search.cro.ie/company/CompanySearch.aspx")
inputElement = driver.find_element_by_id("ctl00_ContentPlaceHolder1_textCompanyName")
inputElement.send_keys("limo")
inputElement.send_keys(Keys.ENTER)
links = driver.find_elements_by_xpath("//*[@id='ctl00_ContentPlaceHolder1_GridView1']/tbody/tr/td/a")

Keybase proof

I hereby claim:

  • I am nbari on github.
  • I am nbari (https://keybase.io/nbari) on keybase.
  • I have a public key whose fingerprint is 38A2 1ADF 535C 36C3 9EF0 320F 4480 2F8C 91F6 6E10

To claim this, I am signing this object:

@nbari
nbari / http2Push.go
Created February 18, 2017 11:21
HTTP/2 Push example
// HTTP/2 Push example using violetear
//
// Create certificate with:
// https://golang.org/src/crypto/tls/generate_cert.go
// go run generate_cert.go -host localhost,127.0.0.1 (will create cer.pem and key.pem)
//
// To test
// go run main.go and open browser using https://localhost:8000
package main
@nbari
nbari / errorHandler.go
Created March 12, 2017 18:29
violetear prototype for a centralized HTTP error handling
package main
import (
"fmt"
"log"
"net/http"
"time"
v "github.com/nbari/violetear"
)
@nbari
nbari / makefile
Created March 17, 2017 09:55
define variable within makefile rule
.PHONY: all test clean
GLOBAL="spirituosen"
all:
@echo ${GLOBAL}
test:
$(eval GLOBAL="trinken")
@echo ${GLOBAL}
@nbari
nbari / restart-elk.yml
Created August 22, 2017 16:14
ansible rolling restart elasticsearch node
# Elasticsearch Rolling restart using Ansible
#
# Perform a rolling restart of the elasticsearch nodes and wait for the cluster
# to stabilize before continuing processing nodes.
#
# The handlers are chained together using notify to perform the following process:
#
# 1. Disable shard allocation on the cluster
# 2. Restart the elasticsearch node process
# 3. Wait for the node to rejoin the cluster
@nbari
nbari / remotes.go
Last active September 16, 2017 11:51
find git remotes
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"os/exec"
"path/filepath"