Skip to content

Instantly share code, notes, and snippets.

View jphalip's full-sized avatar

Julien Phalip jphalip

View GitHub Profile
@jphalip
jphalip / gist:68eb9819da31673c11cbec15807cd8ef
Created February 23, 2025 16:56
Access a pod and execute a command
function pod_exec() {
POD_NAME_PATTERN=$1
ARGS="${@:2}"
kubectl exec -it $(kubectl get pods --field-selector=status.phase=Running -o name | grep -m1 $POD_NAME_PATTERN | cut -d'/' -f 2) -- bash -c "$ARGS"
}
function pod_bash() {
pod_exec $1 bash
}
@jphalip
jphalip / tmux-qol.sh
Created January 18, 2025 22:45
Quality-of-life shell functions and aliases for Tmux
# If no tmux sessions exist, starts a new session
# If sessions exist, attaches and shows session picker
function tm() {
tmux ls &> /dev/null
if [ $? -eq 1 ]
then
# No sessions exist, start new one
tmux
else
# Sessions exist, attach and show session picker
@jphalip
jphalip / .vimrc
Created October 21, 2024 17:47
Some custom Vim key mappings
" Set the leader key to comma for custom mappings
let mapleader = ","
" Set timeout for key sequences (in milliseconds)
set timeout timeoutlen=500
" Use system clipboard for all yank, delete, and put operations
set clipboard=unnamedplus
" Insert new lines without leaving normal mode
# Lorem ipsum dolor sit amet
consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Laoreet id donec ultrices tincidunt arcu non sodales neque sodales. Lorem ipsum dolor sit amet
consectetur adipiscing elit pellentesque. Eget duis at tellus at urna condimentum mattis pellentesque.
Cras semper auctor neque vitae tempus quam pellentesque. Nibh tortor id aliquet lectus proin nibh nisl
@jphalip
jphalip / client.java
Last active February 18, 2023 02:22
SSDP sample code
public static void main(String[] args) throws IOException {
System.setProperty("java.net.preferIPv4Stack", "true");
int PORT = 1900;
String MULTICAST_GROUP_IPV4 = "239.172.243.75";
InetAddress LOCALHOST = Inet4Address.getByName("127.0.0.1");
byte[] requestBytes = SEARCH_MESSAGE;
MulticastSocket socket = new MulticastSocket(new InetSocketAddress(LOCALHOST, 0));
socket.setLoopbackMode(false);
socket.setInterface(LOCALHOST);
DatagramPacket packet = new DatagramPacket(
# Takes two parameters: target branch and commit message.
# Does a hard reset on the target branch then adds a single commit with the diff
# between the two branches. Sort of simulates a rebase but without having to
# resolve potential conflicts in intermediary commits.
function git-hard-rebase() {
# Parameter validation
if [ "$#" -ne 2 ]; then
echo "Usage: git-hard-rebase <branch-to-rebase-on> <commit-message>"
return 1
fi
@jphalip
jphalip / schema.go
Created February 13, 2018 21:53
Forwarding rule data source's schema
Schema: map[string]*schema.Schema{
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
},
"region": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
@jphalip
jphalip / gist:351366e767697069c808bb885160cc78
Created January 25, 2018 19:28
Terraform error during Dataproc cluster creation
$ terraform apply
google_compute_network.cloud: Refreshing state... (ID: cloud)
google_compute_address.cloud: Refreshing state... (ID: projects/XXXXXXXX/regions/us-central1/addresses/cloud-static-ip)
google_compute_subnetwork.cloud_subnet: Refreshing state... (ID: us-central1/cloud-subnet)
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
@jphalip
jphalip / app.js
Last active August 29, 2015 14:27
// Version 1:
// MyApp first gets rendered with empty "data", then gets re-rendered with
// ajax-fetched data after the stores gets hydrated and triggers the update.
import Reflux from 'reflux';
import React from 'react'
import $ from 'jQuery'
var Actions = Reflux.createActions([
'hydrate'
@jphalip
jphalip / gist:95da5f97c02ab10b4966
Created November 15, 2014 14:41
Django core test suite failures
vagrant@djangocore:~$ runtests3.3-sqlite
Testing against Django installed in '/django/django'
Creating test database for alias 'default'...
Creating test database for alias 'other'...
.........................................................................................................................................................................................s........................................................................................................................................x..........................................................................................................................................................................................................................................................ssssssssssss.sssssssss....................................................................................................................................................................ss........................................................................sssssss