Skip to content

Instantly share code, notes, and snippets.

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

Cesar Gimenes crgimenes

🏠
Working from home
View GitHub Profile
@crgimenes
crgimenes / stringToReaderCloser.go
Last active April 11, 2024 15:41
string to io.ReadCloser
package main
import (
"bytes"
"fmt"
"io"
"os"
"strings"
)
@crgimenes
crgimenes / 10_PRINT.lua
Created April 11, 2024 05:16 — forked from nicolas-sabbatini/10_PRINT.lua
The famous one line program 10 PRINT in lua
::_10:: io.write(math.random() < 0.5 and "/" or "\\"); goto _10
@crgimenes
crgimenes / main.go
Created March 3, 2024 02:09
Simple http dump server
package main
import (
"flag"
"fmt"
"log"
"net/http"
"net/http/httputil"
)
@crgimenes
crgimenes / fullauto.cpp
Created February 2, 2024 03:36 — forked from felipemanga/fullauto.cpp
Improved devterm automatic gearbox
// Compile like this: g++ fullauto.cpp --std=c++17 -o fullauto
// Run like this: sudo fullauto &
#include <thread>
#include <chrono>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
@crgimenes
crgimenes / strarray.go
Last active December 14, 2023 21:17
Golang Example of Receiving Arrays or Strings in Same JSON Object
package strarray
import (
"encoding/json"
"errors"
)
var (
// ErrUnsupportedType is returned if the type is not implemented
ErrUnsupportedType = errors.New("unsupported type")
@crgimenes
crgimenes / Update Golang *Nix
Last active November 16, 2023 12:26 — forked from jniltinho/update-golang.sh
update-golang.sh
#!/bin/bash
## Update Golang (Linux/Mac)
go version
## Get Last Stable Version
LAST_VERSION=$(curl -s 'https://go.dev/VERSION?m=text'|head -n1)
os="linux"
if [ "$(uname -s)" = "Darwin" ]; then
@crgimenes
crgimenes / README.md
Last active July 12, 2023 09:42
Example of pagination using PostgreSQL, Golang and SQLx

Configure environment variable

export DATABASE_URL=postgres://postgres@localhost/dbname?sslmode=disable 

Run in CLI

go run main.go -page 1
@crgimenes
crgimenes / json2tuple.py
Created February 14, 2023 14:29
Convert json to tuple (to be used in CSV generation for example)
import json
def json_titles_tuple(payload_json, prefix=''):
jsonobj = json.loads(payload_json)
titles = ()
for key, value in jsonobj.items():
if isinstance(value, dict):
titles += json_titles_tuple(json.dumps(value), prefix + key + '_')
else:
titles += (prefix + key,)
@crgimenes
crgimenes / main.go
Last active February 6, 2023 23:18
Web Scraping with Golang
package main
import (
"context"
"log"
"github.com/chromedp/chromedp"
)
func main() {
@crgimenes
crgimenes / main.go
Created May 21, 2020 21:11
Detect server and client ip and port
package main
import (
"fmt"
"net"
"net/http"
"github.com/gorilla/mux"
)