Skip to content

Instantly share code, notes, and snippets.

View BenRhouma's full-sized avatar

Ben Rhouma Zied BenRhouma

  • Cimpress
  • Tunisia
View GitHub Profile
@BenRhouma
BenRhouma / powershell_pgsql
Created April 2, 2019 14:40
call postgres from powershell
$path="path/to/pgsql/folder"
$ConnectionString = "Server=127.0.0.1;Port=5432;Database=monolith_farm;Uid=postgres;Pwd=root;"
[Reflection.Assembly]::LoadFrom("$path/Npgsql.dll") > $null
function Get-CommandObject {
@BenRhouma
BenRhouma / 0_reuse_code.js
Created January 12, 2016 08:57
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
public static string GenerateOctopusSlug(this string phrase)
{
string str = phrase.RemoveAccent().ToLower();
str = Regex.Replace(str, @"[\.+@$*%\^]", "-");
// invalid chars
str = Regex.Replace(str, @"[^a-z0-9\s-]", "");
// convert multiple spaces into one space
str = Regex.Replace(str, @"\s+", " ").Trim();
// cut and trim
* stop one
touch ~/.bash_profile
chmod a+x ~/.bash_profile
* stop two > bash_profile
SSHAGENT=/usr/bin/ssh-agent
SSHAGENTARGS="-s"
if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then
eval `$SSHAGENT $SSHAGENTARGS`
@BenRhouma
BenRhouma / pl-sql long operation
Last active January 12, 2016 09:11
Long plsql operation monitoring
declare
rindex BINARY_INTEGER;
slno BINARY_INTEGER;
totalwork NUMBER := 0; -- Total number of structures
worksofar NUMBER := 0; -- Number of structures processed
cursor cons is select * from CONSUMPTION;
// you must add this line to the build.scala :: play.Project(.........).settings(....)
// .settings(aspectjSettings: _*).settings(inputs in Aspectj <+= compiledClasses,products in Compile <<= products in Aspectj, products in Runtime <<= products in Compile)
package filters;
import models.User;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
@BenRhouma
BenRhouma / Upper First letter After _
Last active January 12, 2016 09:11
Upper First letter After _
public String treat(String str){
final Pattern pattern = Pattern.compile("([^_.]*)[_]*");
Matcher matcher = pattern.matcher(str);
String ret ="";
while(matcher.find()){
if(!matcher.group(1).equals(""))
ret += upperFirstCharacter(matcher.group(1));
}
return ret;