Skip to content

Instantly share code, notes, and snippets.

View biniama's full-sized avatar

Biniam biniama

View GitHub Profile
@schacon
schacon / gist:942899
Created April 26, 2011 19:19
delete all remote branches that have already been merged into master
$ git branch -r --merged |
grep origin |
grep -v '>' |
grep -v master |
xargs -L1 |
awk '{split($0,a,"/"); print a[2]}' |
xargs git push origin --delete
@Isammoc
Isammoc / .travis.yml
Created July 12, 2012 22:29 — forked from berngp/.travis.yml
Grails Travis YML file
language: java
jdk:
- openjdk7
- oraclejdk7
before_install:
- sudo add-apt-repository -y ppa:groovy-dev/grails
- sudo apt-get update
- sudo apt-get -y install grails-ppa # not sure if necessary
@quiver
quiver / new_task.py
Created October 6, 2012 12:15
rabbitmq : dead letter exchange example with python/pika
#!/usr/bin/env python
# http://www.rabbitmq.com/tutorials/tutorial-two-python.html
import pika
import sys
connection = pika.BlockingConnection(pika.ConnectionParameters(
host='localhost'))
channel = connection.channel()
message = ' '.join(sys.argv[1:]) or "Hello World!"
@scaryguy
scaryguy / change_id_column
Last active March 21, 2022 15:24
How to reset ID column of a PostgreSQL table to let auto incrementation begin from 1?
# See your sequence name inside psql console with \ds command.
ALTER SEQUENCE seq RESTART WITH 1;
# Update sequence
UPDATE table_name SET id=nextval('seq');
@jconwell
jconwell / ForwarderActor.java
Last active January 1, 2016 13:49
Akka actor that takes another ActorRef as a constructor argument, and forwards all incoming messages to the one passed in. This is useful for unit tests, where you can pass in a JavaTestKit instance to the constructor and all messages passed to this actor will be forwarded to the JavaTestKit instance.
package com.turbo.akka;
import akka.actor.ActorRef;
import akka.actor.UntypedActor;
/**
* Simple actor that takes another actor and forwards all messages to it.
* Useful in unit testing for capturing and testing if a message was received.
* Simply pass in an Akka JavaTestKit probe into the constructor, and all messages
* that are sent to this actor are forwarded to the JavaTestKit probe
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@Diego81
Diego81 / WordCounter.scala
Last active December 12, 2021 12:36
Simple Word Counter implemented using Akka
import akka.actor.{ Actor, ActorRef, Props, ActorSystem }
case class ProcessStringMsg(string: String)
case class StringProcessedMsg(words: Integer)
class StringCounterActor extends Actor {
def receive = {
case ProcessStringMsg(string) => {
val wordsInLine = string.split(" ").length
sender ! StringProcessedMsg(wordsInLine)
@Kartones
Kartones / postgres-cheatsheet.md
Last active June 7, 2024 13:13
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@nosmokingpistol
nosmokingpistol / Swagger Setup for Embedded Jetty Server.md
Last active November 8, 2023 11:13
Setup Swagger with an embedded Jetty Server

Swagger Setup for Embedded Jetty Server

In setting up a Jetty server with Jersey servlets, you may choose to use an embedded Jetty server setup. (See here for how to setup an embedded Jetty server). In this gist, we'll go through how to setup Swagger for this setup. I am using Swagger 1.5, Maven 3.3.3, Jersey 1.8, and Jetty 7.3. Make sure you add all dependencies to your pom.xml.

In the Swagger Core setup, the current official recommendations involve an Application class, or a web.xml, neither of which are used in an embedded Jetty server setup. To add Swagger to your embedded Jetty Server, you must do 3 things:

  1. Add the package scanning packages to your servlets which will serve your REST API.
  2. Add the Swagger package scanning servlet.
  3. P
@oanhnn
oanhnn / using-multiple-github-accounts-with-ssh-keys.md
Last active June 10, 2024 16:19
Using multiple github accounts with ssh keys

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.