Skip to content

Instantly share code, notes, and snippets.

@ripx80
ripx80 / web-servers.md
Created December 28, 2018 09:16 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
The long way of json decoding
var result map[string]interface{}
err = json.NewDecoder(res.Body).Decode(&result)
if err != nil {
fmt.Printf("JSON Decode ERROR: %s", err)
check.GoExit("")
}
@ripx80
ripx80 / gist:fdf8ce4daa1d2cf558f13eaf9e74cff3
Last active February 13, 2019 15:41
Go Patterns I found
// https://golang.org/doc/effective_go
// https://nanxiao.gitbooks.io/golang-101-hacks/content/
## For Loops
// Reverse a
for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
a[i], a[j] = a[j], a[i]
}
## Type Switch
@ripx80
ripx80 / main.go
Created February 21, 2019 12:16
GO: Container from scratch
package main
import (
"fmt"
"os"
"os/exec"
"syscall"
)
func main() {
@ripx80
ripx80 / fire-alert.sh
Last active October 28, 2020 15:03
fire up a alert in alertmanager
#!/bin/bash
# change url and cookie if needed
name=dummy-alert
url='http://localhost:8000/alertmanager/api/v1/alerts'
COOKIE=''
echo "firing up alert $name"
# change url o

Keybase proof

I hereby claim:

  • I am ripx80 on github.
  • I am ripx80 (https://keybase.io/ripx80) on keybase.
  • I have a public key ASCw2NW_VWNowBG1kk87IK1ndqCDP18iG7aZ9Is1tlzeZgo

To claim this, I am signing this object:

@ripx80
ripx80 / main.rs
Created March 24, 2021 14:19
example for serde to implement serialize_with and deserialize_with for a u8 array
extern crate serde;
use base64;
use hex::FromHex;
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
use std::convert::TryFrom;
#[derive(Serialize, Deserialize, Debug)]
pub struct Config {
#[serde(serialize_with = "as_base64", deserialize_with = "from_base64")]
key: [u8; 32],
@ripx80
ripx80 / main.rs
Created April 7, 2021 15:04
tictactoe
/*
Question: https://jrms-random-blog.blogspot.com/2021/03/a-google-interview-question.html
Shor: building a tic tac toe winning algo
Solutions
map: 4x4
3 O O O O 8
2 O O O O 8
1 O O O O 8
@ripx80
ripx80 / route_dump.c
Created March 10, 2022 09:18 — forked from cl4u2/route_dump.c
Linux route monitoring example
/*
iflist.c : retrieve network interface information thru netlink sockets
(c) Jean Lorchat @ Internet Initiative Japan - Innovation Institute
v1.0 : initial version - Feb 19th 2010
This file was obtained at the following address :
http://www.iijlab.net/~jean/iflist.c
@ripx80
ripx80 / index.php
Created September 16, 2022 08:15 — forked from wiesson/index.php
Click 2 Call - XML RPC Example with PHP
<?php
if (!extension_loaded('xmlrpc')) {
echo "PHP xmlrpc extension is not available.";
die;
}
function call($remoteUri, $localUri, $username, $password)
{
$requestParameter = array(
'RemoteUri' => sprintf('sip:%s@sipgate.de', $remoteUri),