Skip to content

Instantly share code, notes, and snippets.

View alanbacelar's full-sized avatar
🏠
Working from home

Alan Bacelar alanbacelar

🏠
Working from home
View GitHub Profile
@alanbacelar
alanbacelar / Chromium Linux.md
Created March 28, 2023 11:47 — forked from marians/Chromium Linux.md
How to install CA certificates and PKCS12 key bundles on different platforms

We install certutil and pk12util if necessary:

sudo apt install libnss3-tools

On Linux, Chromium uses the NSS Shared DB. Check if you have the ~/.pki/nssdb directory:

ls $HOME/.pki/nssdb
@alanbacelar
alanbacelar / auto_select_certificate.json
Created March 27, 2023 13:53 — forked from njh/auto_select_certificate.json
Policy file to configure Chrome/Chromium to automatically select a client certificate (useful for Kiosk mode)
{
"AutoSelectCertificateForUrls": ["{\"pattern\":\"*\",\"filter\":{}}"]
}

FortiClient VPN CLI - Linux

Installation

Before you install the program you also need to install xterm, if this is not already installed, as this program is sometimes used by the client to view the license. To do this open a Terminal and run the following command:

sudo apt-get install xterm
@alanbacelar
alanbacelar / screen.md
Created July 15, 2020 18:30
Linux Tips

Screen

Instalation

sudo apt install screen

Show sessions

screen -ls

Create a new session

screen -S name_of_the_session

SQL Server Snippets


Force drop database

USE master;
ALTER DATABASE [database_name] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DROP DATABASE [database_name];
# WARNING! This will remove:
# - all stopped containers
# - all networks not used by at least one container
# - all images without at least one container associated to them
# - all build cache
docker system prune -a
# Stop all containers
docker stop `docker ps -qa`
@alanbacelar
alanbacelar / cmd.sh
Created October 18, 2017 11:13 — forked from kelvinn/cmd.sh
Example of using Apache Bench (ab) to POST JSON to an API
# post_loc.txt contains the json you want to post
# -p means to POST it
# -H adds an Auth header (could be Basic or Token)
# -T sets the Content-Type
# -c is concurrent clients
# -n is the number of requests to run in the test
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/
@alanbacelar
alanbacelar / iterm2_setup.md
Last active September 30, 2017 02:06
iTerm2 Setup

Word jumping

Go to Preferences > Profiles > Keys and add folowing sequences:

FOR ACTION SEND
⌘← "Send Hex Code" 0x01
⌘→ "Send Hex Code" 0x05
⌥← "Send Escape Sequence" b
⌥→ "Send Escape Sequence" f
@alanbacelar
alanbacelar / MainActivity.java
Created April 4, 2017 18:17 — forked from riggaroo/MainActivity.java
Online Presence with Firebase and Android based off article https://firebase.googleblog.com/2013/06/how-to-build-presence-system.html . Read the article as it explains the whole .onDisconnect().removeValue() nicely.
private void initialiseOnlinePresence() {
final DatabaseReference onlineRef = databaseReference.child(".info/connected");
final DatabaseReference currentUserRef = databaseReference.child("/presence/" + userId);
onlineRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(final DataSnapshot dataSnapshot) {
Log.d(TAG, "DataSnapshot:" + dataSnapshot);
if (dataSnapshot.getValue(Boolean.class)){
currentUserRef.onDisconnect().removeValue();
currentUserRef.setValue(true);
VACUUM
VACUUM [tablename]
VACUUM FULL
VACUUM FULL [tablename]
REINDEX TABLE mytable
REINDEX INDEX myindex