Skip to content

Instantly share code, notes, and snippets.

Halil Kaskavalci kaskavalci

Block or report user

Report or block kaskavalci

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kaskavalci
kaskavalci / unique-strings.go
Created Jul 19, 2018
Remove duplicates from a string array in go
View unique-strings.go
func unique(tokens *[]string) {
v := reflect.ValueOf(tokens).Elem()
if v.Len() <= 1 {
return
}
sort.Strings(*tokens)
i := 0
for j := 1; j < v.Len(); j++ {
if (*tokens)[i] == (*tokens)[j] {
@kaskavalci
kaskavalci / download.js
Created Mar 15, 2018
humble bundle download all
View download.js
// Execute this from browser console
// Tested on Chrome. Firefox does not work. Even pop-up blocker is disabled it still blocks opening new windows.
// Things to do:
// Enable option Download PDF files instead of automatically opening them in Chrome in chrome
// Allow popups
Array.from(document.querySelectorAll('a')).filter(a => a.hostname.startsWith('dl.')).map((v)=>{v.setAttribute('target','_blank'); v.classList.remove('a'); return v}).forEach(v=>{window.open(v.href,'_blank'); console.log(v.href)})
View keybase.md

Keybase proof

I hereby claim:

  • I am kaskavalci on github.
  • I am kaskavalci (https://keybase.io/kaskavalci) on keybase.
  • I have a public key whose fingerprint is E6F2 56B2 165E 1C63 2120 D327 1A9E 56C5 C682 88F3

To claim this, I am signing this object:

@kaskavalci
kaskavalci / pre-commit.bash
Created Jan 25, 2018
pre-commit hook for sqlinter
View pre-commit.bash
if [[ ! $(which gem) ]]; then
echo "You don't have gem installed. Go install it."
exit 1
fi
if [[ ! $(which sqlint) ]]; then
gem install sqlint
fi
git diff --cached --name-status | xargs -0 | while read st file; do
@kaskavalci
kaskavalci / untar-dir.sh
Created Sep 15, 2017
Untar all files in a directory to unique directories
View untar-dir.sh
# Change file extension if needed
for f in *.tgz ; do mkdir "${f%%.*}" && tar xzf $f -C "${f%%.*}" ; done
View nomad-consul-communication
�ò���l�$X������`�@��!4I4ԡ7�,�2�
~1�~�GET /v1/agent/services HTTP/1.1
Host: localhost:8500
User-Agent: Go-http-client/1.1
Accept-Encoding: gzip
l�$X �hh��`2@!4��7�,I4��u:
~1�~1�HTTP/1.1 200 OK
Content-Type: application/json
Date: Thu, 10 Nov 2016 18:46:04 GMT
View git_aliases.sh
##
##You better change these:
##
git config --global user.name "Name Surname?"
git config --global user.email "mail@domain.com"
##
##Paste as it is
##
git config --global alias.s "status -suno"
git config --global alias.l "log --oneline --decorate"
View runnable.java
Runnable runner = new Runnable() {
@Override
public void run() {
File index = new File(getMyURL());
if (index.exists()) {
browser.setUrl(getMyURL());
}
browser.refresh();
}
}
View redirect_stdout.c
freopen("NUL", "a", stdout); //redirect stdout to null again
dup2(stdout_save, STDOUT_FILENO); //restore the previous state of stdout
setvbuf(stdout, NULL, _IONBF, MDT_BUFSIZE); //disable buffer to print to screen instantly
View save_stdout_status.c
int stdout_save;
char buffer[BIG_ENOUGH];
fflush(stdout); //clean everything first
stdout_save = dup(STDOUT_FILENO); //save the stdout state
freopen("NUL", "a", stdout); //redirect stdout to null pointer
setvbuf(stdout, buffer, _IOFBF, 1024); //set buffer to stdout
You can’t perform that action at this time.