Skip to content

Instantly share code, notes, and snippets.

View jarek-przygodzki's full-sized avatar

Jarek Przygódzki jarek-przygodzki

View GitHub Profile
@nicoulaj
nicoulaj / clean-hsperfdata.sh
Created August 7, 2012 15:08
Clean Java hsperfdata files
#!/bin/sh
# Looks for /tmp/hsperfdata_* files leaved by unclean Java processes
# shutdowns and remove them.
# This should be executed by a user without sufficient rights to delete
# other users files...
for hsperfdata in /tmp/hsperfdata_*/*; do
ps -p `basename ${hsperfdata}` &> /dev/null || rm -vf $hsperfdata
done
@ConnorDoyle
ConnorDoyle / BoundedEventBuffer.scala
Last active January 3, 2016 23:09
A thread-safe, bounded, mutable message buffer in Scala.
// implementation...
import scala.collection.mutable.{ ArrayBuffer, ObservableBuffer, Undoable }
import scala.collection.script.{ Message, Include }
import java.io.Closeable
import java.util.concurrent.LinkedBlockingQueue
/**
* A thread-safe, bounded, mutable event buffer.
*/
import java.io._
import java.net._
object Main {
trait StreamTypeInferencer[A, B]
object StreamTypeInferencer {
implicit object InputStreamInputStream
extends StreamTypeInferencer[InputStream, InputStream]
implicit object InputStreamBufferedInputStream
extends StreamTypeInferencer[BufferedInputStream, InputStream]
@jzi96
jzi96 / Oracle delete all tables in schema.sql
Created May 23, 2012 06:05
Oracle delete all tables in schema (data)
SET SERVEROUTPUT ON
exec dbms_output.enable(1000000);
DECLARE
v_typ VARCHAR2(32);
v_name VARCHAR2(32);
v_constraint VARCHAR2(32);
v_sql VARCHAR2(100);
CURSOR c_objekte IS
SELECT typ, NAME
@etorreborre
etorreborre / gist:1371518
Created November 16, 2011 21:40
Tagged Epochtime and Daytime
package object time {
// Unboxed newtypes, credit to @milessabin and @retronym
type Tagged[U] = { type Tag = U }
type @@[T, U] = T with Tagged[U]
class Tagger[U] { def apply[T](t : T) : T @@ U = t.asInstanceOf[T @@ U] }
def tag[U] = new Tagger[U]
trait Day
@lihaoyi
lihaoyi / play.scala
Last active April 18, 2017 08:18
play.scala
/**
* Single-file play framework application! Make sure everything
* works, as this is the test case that un-earthed #371
*/
load.ivy("com.typesafe.play" %% "play" % "2.5.0")
load.ivy("com.typesafe.play" %% "play-netty-server" % "2.5.0")
load.ivy("org.scalaj" %% "scalaj-http" % "2.2.1")
@
@kleptog
kleptog / check_fdb.py
Last active March 6, 2018 07:54
Script to check Docker Swarm fdb
#!/usr/bin/python
from subprocess import check_output as run
import glob
# Get nodes
nodes = run(['docker', 'node', 'ls', '-q']).split()
self = run(['docker', 'node', 'inspect', 'self', '--format={{.ID}}']).strip()
nodeinfo = {}
@kbaesler
kbaesler / associate_sde_stats.sql
Last active March 20, 2018 23:13
Oracle 11g: The post scripts that should be run after refreshing a geodatabase instance.
EXECUTE sys.utl_recomp.recomp_serial('SDE');
ASSOCIATE STATISTICS WITH PACKAGES sde.st_domain_operators, sde.st_relation_operators USING sde.st_domain_stats;
ASSOCIATE STATISTICS WITH INDEXTYPES sde.st_spatial_index USING sde.st_domain_stats;
ASSOCIATE STATISTICS WITH TYPES sde.st_geometry USING sde.st_domain_stats;
@delitescere
delitescere / pwned-passwd.sh
Last active April 10, 2018 04:04
Check a pwned password from the macOS / bash command line
pwned-passwd ()
{
history -d $((HISTCMD - 1));
sha=$(printf $1 | sha1sum | cut -d' ' -f1 | tr [:lower:] [:upper:]);
prefix=${sha:0:5};
suffix=${sha:5};
count=$(curl -Ss https://api.pwnedpasswords.com/range/$prefix | grep $suffix | cut -d':' -f2);
[ -n "$count" ] && echo $count >&2 && return 1;
return 0;
@yangyuqian
yangyuqian / linkns.sh
Last active July 9, 2018 16:48
Create symlinks for network namespaces inside docker containers
#!/bin/bash
# This simple script creates symlinks for network namespaces of docker containers,
# then you can interact to that network namespace with built-in iproute2 on linux.
# See iproute2 convention in: http://man7.org/linux/man-pages/man8/ip-netns.8.html
container_ids=`docker ps -aq`
for cid in $container_ids
do