Skip to content

Instantly share code, notes, and snippets.

View gadelkareem's full-sized avatar
🎯
Focusing

Gadelkareem gadelkareem

🎯
Focusing
View GitHub Profile
@craig-m-unsw
craig-m-unsw / README.md
Last active February 21, 2024 10:08
Parallels (MacOS M1 host) Packer + Vagrant of Ubuntu 20.04 arm64. Installed with cloud-init and configured with Ansible.

parallels Packer (arm64)

A simple Packer + Vagrant install of Ubuntu 20.04 (Focal Fossa) LTS server for arm64, to run from my M1 Mac on Parallels Pro (17.1). Currently on MacOS Monterey.

Packer will run the ansible playbook.yml before the machine is shutdown and exported.

The installation is automated by cloud-init (which reads user-data). The file meta-data just needs to be an empty text file (you need to create this - no blank files or folders allowed in gists).

ubuntu2004/
@gboudreau
gboudreau / AuthyToOtherAuthenticator.md
Last active April 23, 2024 13:36 — forked from Ingramz/AuthyToOtherAuthenticator.md
Export TOTP tokens from Authy
@blaskovicz
blaskovicz / template.html
Created June 30, 2017 18:01
Golang template features (nested variables, range over array, index into map, conditionals)
<div class="levels">
{{ $groups := .LevelGroups }}
{{ $groupedLevels := .Levels }}
{{ $completeLevels := .CompleteLevels }}
{{ if $groupedLevels }}
{{ range $group := $groups }}
<div class="intro"><h2>{{$group}}</h2></div>
{{ range index $groupedLevels $group }}
<a href="/level/{{.Number}}" class="{{if index $completeLevels .Number}}complete{{end}}">
<span class="level">{{.Number}} </span>
#!/bin/bash
# All credit goes to Marek Bosman.
# Source: https://marekbosman.com/site/automatic-update-of-cloudflare-ip-addresses-in-nginx/
# Location of the nginx config file that contains the CloudFlare IP addresses.
CF_NGINX_CONFIG="/etc/nginx/cloudflare"
# The URLs with the actual IP addresses used by CloudFlare.
CF_URL_IP4="https://www.cloudflare.com/ips-v4"
@azhararmar
azhararmar / Symfony - Manual User Authentication
Last active June 16, 2023 15:35
Manually Authenticate User In Symfony
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
// Manually authenticate user in controller
$token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
$this->get('security.token_storage')->setToken($token);
$this->get('session')->set('_security_main', serialize($token));
@hammady
hammady / solr.service
Created January 9, 2017 08:18
systemd service file for Apache SOLR
# put this file in /etc/systemd/system/ as root
# below paths assume solr installed in /opt/solr, SOLR_PID_DIR is /data
# and that all configuration exists in /etc/default/solr.in.sh which is the case if previously installed as an init.d service
# change port in pid file if differs
# note that it is configured to auto restart solr if it fails (Restart=on-faliure) and that's the motivation indeed :)
# to switch from systemv (init.d) to systemd, do the following after creating this file:
# sudo systemctl daemon-reload
# sudo service solr stop # if already running
# sudo systemctl enable solr
# systemctl start solr
@Lucent
Lucent / watchhistory.sh
Last active April 3, 2024 22:48
View Plex watch history by user on Synology
#!/bin/bash
db_loc="/volume1/Plex/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db"
names=$(sqlite3 "$db_loc" "SELECT name from accounts;")
counter=0
while read -r name; do
let counter++
echo "$counter : $name"
nameArray[counter]=$name
done <<< "$names"
read index
@evalphobia
evalphobia / README.md
Last active February 22, 2024 18:28
Golang Benchmark: gob vs json

tl;dr

  • JSON is faster for small size data
    • map (key size < 50 and Unmarshalling intensive workload)
    • single struct
  • gob is faster for big size data
    • map (key size > 50 or Marshalling intensive workload)
    • slice

(old) about

You can ssh into the VM by finding the IP (from kubectl config view) and using username "docker" password "tcuser":
ssh docker@192.168.XX.XX
@vielhuber
vielhuber / script.sh
Last active April 18, 2024 09:11
PostgreSQL: Backup and restore export import pg_dump with password on command line #sql
# best practice: linux
nano ~/.pgpass
*:5432:*:username:password
chmod 0600 ~/.pgpass
# best practice: windows
edit %APPDATA%\postgresql\pgpass.conf
*:5432:*:username:password
# linux