Skip to content

Instantly share code, notes, and snippets.

View hakansel's full-sized avatar
🚕

H. Hakan Akansel hakansel

🚕
View GitHub Profile
@hakansel
hakansel / run.tpl
Created March 31, 2024 20:30 — forked from efrecon/run.tpl
`docker inspect` template to regenerate the `docker run` command that created a container
docker run \
--name {{printf "%q" .Name}} \
{{- with .HostConfig}}
{{- if .Privileged}}
--privileged \
{{- end}}
{{- if .AutoRemove}}
--rm \
{{- end}}
{{- if .Runtime}}
@hakansel
hakansel / repo_status.sh
Last active January 19, 2021 14:37
Check current git repo status.
#!/bin/sh
UPSTREAM=${1:-'@{u}'}
LOCAL=$(git rev-parse @)
REMOTE=$(git rev-parse "$UPSTREAM")
BASE=$(git merge-base @ "$UPSTREAM")
echo $UPSTREAM
echo $LOCAL
echo $REMOTE
@hakansel
hakansel / .bash_aliases
Created December 12, 2020 14:02
Sonarqube 8.6.0 community start, stop, status commands
# add these line to the shell rc.
alias start_sonarqube='
docker run -d \
--name sonarqube \
--rm \
-p 9000:9000 \
-v sonarqube_extensions:/opt/sonarqube/extensions \
--stop-timeout 3600 \
sonarqube:8.6.0-community
'
@hakansel
hakansel / FileReader.java
Created November 3, 2019 20:43
Multithreaded sequential file reader in java.
package io.akansel.filereader;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
@hakansel
hakansel / fn_keys_as_default
Created May 7, 2019 14:00
fn keys as default in magic keyboard in ubuntu
You can try:
sudo bash -c "echo 2 > /sys/module/hid_apple/parameters/fnmode"
If it works you can change this permanently (per the linked wiki page):
echo options hid_apple fnmode=2 | sudo tee -a /etc/modprobe.d/hid_apple.conf
sudo update-initramfs -u -k all
sudo reboot # optional
@hakansel
hakansel / linux-first-to-dos.txt
Last active February 25, 2019 09:02
First todos after installation of linux.
# resize windows with ALT+RightClick
$ gsettings set org.gnome.desktop.wm.preferences resize-with-right-button true
# drag window with ALT+LeftClick
$ gsettings set org.gnome.desktop.wm.preferences mouse-button-modifier '<Alt>'
# change bash to zsh
$ which zsh
$ chsh
# add zsh path to the
@hakansel
hakansel / mongo_join_and_pagination.js
Created August 28, 2018 13:16
Mongo Join and Pagination
// to more performant result, second_collection_field is indexed.
db.runCommand({
aggregate: 'first_collection_name',
pipeline: [
{
$lookup:{
from: 'second_collection_name',
localField: 'first_collection_field',
foreignField: 'second_collection_field',
as: 'joined_second_collection_array_name'
@hakansel
hakansel / coursera_course_video_downloader.js
Last active August 5, 2018 10:13
Download all mp4 videos of week from coursera.
// Go to any week of the course, then open any video
// then
// open chrome console(cmd+shift+c or F12 or ctrl+shift+c) and paste this content + enter
// then copy output to terminal + enter
// ATTENTION
// replace SET_HERE with your course name in url i.e https://www.coursera.org/learn/COURSE_NAME/home/welcome
var courseName = "SET_HERE";
var lessons = document.getElementsByClassName('lesson-name');
for(var i = 0; i < lessons.length; i++){
if((lessons[i].parentElement.getAttribute('aria-expanded') == 'false')) {
# color, editor color prefs
cp -iv ./.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs <to_rel_path>
cp -iv ./.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs <to_rel_path>
cp -iv ./.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs <to_rel_path>
cp -iv ./.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.ui.prefs <to_rel_path>
cp -iv ./.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.jsdt.ui.prefs <to_rel_path>
# to workbench layout prefs
File > Switch Workspace > Other
and copy needed ones
@hakansel
hakansel / server.xml
Created March 16, 2018 07:59
Server.xml diff to provide changes from http to https
<!--
generate selfsigned certificate on *nix machines
keytool -genkey -keyalg RSA -alias <alias_name_generally_company_product> -keystore keystore.jks -storepass <pass_of_certificate> -validity 360 -keysize 2048
-->
<!--
add existing certificate to empty jks
keytool -genkey -alias <alias_name_generally_company_product> -keystore keystore.jks
keytool -importcert -file <your_.cer_file> -keystore keystore.jks -alias <alias_name_generally_company_product>
-->