Skip to content

Instantly share code, notes, and snippets.

@douglas
douglas / update_git_repos.sh
Created October 14, 2011 15:04
Update all git repositories under a base directory
#!/bin/bash
# store the current dir
CUR_DIR=$(pwd)
# Let the person running the script know what's going on.
echo "\n\033[1mPulling in latest changes for all repositories...\033[0m\n"
# Find all git repositories and update it to the master latest revision
for i in $(find . -name ".git" | cut -c 3-); do
@MikeNGarrett
MikeNGarrett / siege
Last active April 3, 2024 03:49
Siege with JSON POST data
# Changed to use content-type flag instead of header: -H 'Content-Type: application/json'
siege -c50 -t60S --content-type "application/json" 'http://domain.com/path/to/json.php POST {"ids": ["1","2","3"]}'
@baybatu
baybatu / groovy-generic-metod-hatasi.md
Last active January 14, 2016 07:46
Groovy Generic Metod Ayıklama Hatası

Groovy'de

// derleme hatası
<T> void execute(Request<T> request) {
  // kodlar
}

tarzı bir metot imzası ayıklama hatasına(parsing error) sebep olur.

@baybatu
baybatu / creditcard-parser.js
Last active January 26, 2016 07:44
Parses credit card number with 16 characters into groups including 4 characters.
/*
* Example usage: parseCreditCard('1234567890123456') -> [ '1234', '5678', '9012', '3456' ]
*/
function parseCreditCard(cardNumber) {
return cardNumber.match(/.{1,4}/g);
}
@baybatu
baybatu / see-java-jar-file-content.md
Created March 16, 2016 07:21
Listing .jar file content from command-line
jar tf my-jar-file.jar
@yusufsoysal
yusufsoysal / gist:47442b5ed1131c88bfff559820836a4e
Created March 18, 2017 16:36
Intellij IDEA JUnit4 Test Class Template
import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
#parse("File Header.java")
#set($lastIndex = $CLASS_NAME.lastIndexOf(".") + 1)
#set($onlyClassName = $CLASS_NAME.substring($lastIndex))
@safaorhan
safaorhan / Utils.java
Last active October 3, 2022 13:36
Java / Android TC Kimlik No Doğrulama
// Yalnızca UI onayı için kullanılmalıdır
// İş önemi olan durumlarda bu api'yi kullanmalısınız:
// https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?op=TCKimlikNoDogrula
private boolean isTCKNCorrect(String id) {
if (id == null) return false;
if (id.length() != 11) return false;
char[] chars = id.toCharArray();
@okanmenevseoglu
okanmenevseoglu / postgres-create-drop-index-online.sql
Last active January 29, 2018 11:28
Create/Drop a database index online (without locking the table) on PostgreSQL
CREATE INDEX CONCURRENTLY {indexName} ON {tableName} ({columnName});
DROP INDEX CONCURRENTLY {indexName};
@okanmenevseoglu
okanmenevseoglu / bootable-usb-install-drive-for-macos.sh
Last active February 7, 2018 08:45
How to Make a Bootable macOS USB Install Drive
# 1) Download Mac Version to install from App Store
# 2) Put a USB stick at least 8 GB
# 3) Open Terminal and enter the following command:
sudo /Applications/Install\ macOS\ High\ Sierra.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume
@okanmenevseoglu
okanmenevseoglu / pg_stat_activity.sql
Created February 13, 2018 12:50
Viewing the Activity Table on PostgreSQL in detail and Terminating a pid
-- To be able to use these in full detail, you must have the necesarry role authentication
-- Find activity list on DB
select * from pg_stat_activity
-- Find pid, user name, query, backend start date, transaction start date, query start date and the longest running sql times that are active and idle in transaction
SELECT pid, usename, query, backend_start, xact_start, query_start, (now() - query_start) AS run_time FROM pg_stat_activity WHERE state IN ('active', 'idle in transaction') ORDER BY query_start
-- Terminate the sql with the given pid
SELECT