Skip to content

Instantly share code, notes, and snippets.

View jpalawaga's full-sized avatar
👅
being silly

James Palawaga jpalawaga

👅
being silly
View GitHub Profile
@jpalawaga
jpalawaga / commas.json
Last active July 18, 2022 18:53
Json with Commas
[
{
"id": 1,
"text": "abc,xyz\"",
"obj": {
"abc": "xyz,123\""
},
"arr": [
"123\",456"
]
@jpalawaga
jpalawaga / nil_interface_value.go
Last active April 7, 2022 04:55
Some code that will nil an interface's value while leaving its type intact.
package main
import (
"fmt"
"unsafe"
"github.com/google/uuid"
)
// NullInterfaceValue takes an interface ref, constructs an new struct from
@jpalawaga
jpalawaga / nilling_interface_values.go
Created February 8, 2022 02:56
Nilling interface values but not types
package main
import (
"fmt"
"unsafe"
"github.com/AlekSi/pointer"
)
// interface defs from reflect library
@jpalawaga
jpalawaga / isuuid5.cc
Created August 26, 2019 18:55
Is UUID version 5 or not?
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;
int main() {
cout << "Enter uuid: ";
@jpalawaga
jpalawaga / deprecation_example.py
Last active October 31, 2016 18:59
Using Python Deprecations Correctly
import warnings
def bad_deprecation():
warnings.warn("Please use new.function()!. Remove by 12/15/2016",
DeprecationWarning)
def good_deprecation():
warnings.warn("Please use new.function()!. Remove by 12/15/2016",
DeprecationWarning, stacklevel=2)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jpalawaga
jpalawaga / gist:c2047e281192714234fe
Created November 23, 2014 01:18
That one script I use to break that kid's scam site after I was phished.
import os;
import string
import random
from random import sample, choice
chars = string.letters + string.digits
length = 8
f=open('words.txt')
lines=f.readlines()
#include <iostream>
class myClass {
private:
int * test;
public:
myClass() {
test = new int(4);
}
int * getPtr() { return test; }