Skip to content

Instantly share code, notes, and snippets.

@gkazior
gkazior / memusg
Last active August 29, 2015 14:12 — forked from netj/memusg
#!/usr/bin/env bash
# memusg -- Measure memory usage of processes
# Usage: memusg COMMAND [ARGS]...
#
# Author: Jaeho Shin <netj@sparcs.org>
# Created: 2010-08-16
set -um
# check input
[ $# -gt 0 ] || { sed -n '2,/^#$/ s/^# //p' <"$0"; exit 1; }
@gkazior
gkazior / cas-get.sh
Last active September 22, 2023 12:19 — forked from dodok1/cas-get.sh
#!/bin/bash
# Usage: cas-get.sh {url} {username} {password} # If you have any errors try removing the redirects to get more information
# The service to be called, and a url-encoded version (the url encoding isn't perfect, if you're encoding complex stuff you may wish to replace with a different method)
DEST="$1"
ENCODED_DEST=`echo "$DEST" | perl -p -e 's/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg' | sed 's/%2E/./g' | sed 's/%0A//g'`
#IP Addresses or hostnames are fine here
CAS_HOSTNAME=galaxy:9143
CREATE OR REPLACE FUNCTION fvGetHash512(pv_Arg IN VARCHAR2)
RETURN VARCHAR2
IS LANGUAGE java name 'Hash512.getHash512(java.lang.String) return java.lang.String';
/
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Hash512" AS
import java.lang.*;
import java.security.MessageDigest;
public class Hash512 {
public static String getHash512(String arg) {
@gkazior
gkazior / check_caller
Last active August 29, 2015 14:15
Check if the caller of a script is also an owner of the script
#!/bin/bash
true=0
false=1
##
# check if the caller is the same as the owner of the current script
# otherwise the following problem is possible:
# root calls you script and creates a file with root ownership
# then you need root to do anythink with the file
@gkazior
gkazior / logger.prod.xml
Last active August 29, 2015 14:16
Log appender rolled by day
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<append>true</append>
<encoder>
<pattern>%date %message %n%rEx{full}</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--log files are created in logs with name different for each day-->
<fileNamePattern>${application.home}/logs/app-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<!--log files are created in separate folder for each day-->
<!--<fileNamePattern>${application.home}/logs/%d{yyyy/MM/dd}/tumrestapi-%d{yyyy-MM-dd}.%i.log</fileNamePattern>-->
import java.security.SecureRandom;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.SecretKeyFactory;
import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
/*
* PBKDF2 salted password hashing.
* Author: havoc AT defuse.ca
@gkazior
gkazior / gist:78521d8f00e99cdb140f
Last active August 29, 2015 14:27 — forked from jtheoof/gist:2880413
pre-commit SVN hook to prevent a commit if Jenkins is building or build is broken
#!/bin/sh
# PRE-COMMIT HOOK
#
# The pre-commit hook is invoked before a Subversion txn is
# committed. Subversion runs this hook by invoking a program
# (script, executable, binary, etc.) named 'pre-commit' (for which
# this file is a template), with the following ordered arguments:
#
# [1] REPOS-PATH (the path to this repository)
@gkazior
gkazior / build.sbt
Last active September 22, 2015 09:13 — forked from seratch/build.sbt
Scala School - Testing with specs2 examples
organization := "com.gk"
name := "sandbox"
version := "0.1"
scalaVersion := "2.9.1"
libraryDependencies ++= Seq(
"junit" % "junit" % "4.9" % "test" withSources(),
@gkazior
gkazior / SendEmail.scala
Created October 1, 2015 21:20
Send email in scala play
def sendEmail(emailTo: String, emailFrom: String, subject: String, body: String) = {
import com.typesafe.plugin._
val mail = use[MailerPlugin].email
mail.setRecipient(emailTo)
mail.setFrom(emailFrom)
mail.setSubject(subject)
mail.send(body)
}
@gkazior
gkazior / FutureBasicsWs.sc
Created October 8, 2015 10:24
Futures samples
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent._
import scala.concurrent.duration._
import scala.util._
val timeout = 1.seconds
//> timeout : scala.concurrent.duration.FiniteDuration = 1 second