Skip to content

Instantly share code, notes, and snippets.

@turgay
turgay / app.coffee
Last active August 29, 2015 14:14 — forked from ericallam/app.coffee
event = require('pilot/event')
Anchor = require('ace/anchor').Anchor
doc = ace_editor.session.getDocument()
editablePositions = [[1, 0, 2, 0]] # allow editong only the second row
jQuery.each editable, (index, row) ->
editablePositions.push [new Anchor(doc, row[0], row[1]), new Anchor(doc, row[2], row[3])]
Range = require('ace/range').Range
@turgay
turgay / SplitByCamelCase.groovy
Created July 21, 2015 15:23
Split camel case strings from file into words
new File("camelcase.txt").eachLine { line->
def tokens = line.split("(?<!(^|[A-Z]))(?=[A-Z])|(?<!^)(?=[A-Z][a-z])")
def words = []
tokens.each {
words.push(it.capitalize())
}
println words.join(" ")
@turgay
turgay / override_input.py
Created October 4, 2015 11:44
Python override builtin input function
import __builtin__
def fake_input(prompt):
print prompt
return "trgy"
__builtin__.raw_input = fake_input
name = raw_input("Enter your name >")
@turgay
turgay / barber.go
Created October 14, 2015 15:35 — forked from kachayev/barber.go
Solve "Sleeping Barber Problem" with Golang (more about problem - http://en.wikipedia.org/wiki/Sleeping_barber_problem)
package main
import (
"fmt"
"time"
"math/rand"
)
const (
CUTTING_TIME = 20
@turgay
turgay / DuplicateFinder.clj
Last active July 15, 2020 03:11
Find duplicates in a sequence using Clojure
(defn extract-names [seq]
(for [lib seq :let [dot-index (.indexOf lib ".")]]
(subs lib 0 (- dot-index 2))))
;(println (extract-names ["x-security-1.0.7.jar" "aksis-1.0.jar" "antlr-2.7.6.jar"]))
(defn dups [seq]
(for [[id freq] (frequencies seq) ;; get the frequencies, destructure
:when (> freq 1)] ;; this is the filter condition
Search by timestamp:
timestamp:["2014-12-01 00:00:00.000" TO "2014-12-31 00:00:00.000"]
@turgay
turgay / sources.list
Created September 26, 2018 06:39 — forked from rohitrawat/sources.list
Ubuntu 16.04 Xenial default /etc/apt/sources.list
#deb cdrom:[Ubuntu 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.2)]/ xenial main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
Prune all branches locally not existing in remote in Git:
git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done
@turgay
turgay / terraform-get-by-name
Created December 14, 2019 00:25
Terraform: Get a VPC by name
//file: provider.tf
provider "aws" {
region = "us-east-1"
}
//file: vpc.tf
variable "vpc_name" {}
data "aws_vpc" "selected" {
tags = {
1- Install
brew install bash
2- List bashes
$ which -a bash
/usr/local/bin/bash
/bin/bash
3- Check versions
$ /usr/local/bin/bash --version
GNU bash, version 5.0.0(1)-release (x86_64-apple-darwin18.2.0) ...
$ /bin/bash --version