Skip to content

Instantly share code, notes, and snippets.

@shrys
shrys / launch.json
Created June 10, 2024 17:46
ng chrome attach
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "attach",
"name": "Attach to Chrome",
@shrys
shrys / main.py
Created November 8, 2021 07:41
filter ip addresses: tabbed, jsonified text
#!/usr/bin/env python
import json
def contains_ip(line: str):
if type(line) is not str:
return
dots = line.count('.')
return dots > 0 and dots % 3 == 0 and len(line) <= 15
@shrys
shrys / main.py
Last active June 2, 2020 21:47
tweet/retweet notification of a user on slack hook
import tweepy
import time
import sys
import inspect
import requests
import json
consumer_key = 'xxxxxxxxxxxxxxxxxxx'
consumer_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
access_token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
@shrys
shrys / index.ts
Last active June 10, 2020 13:47
Nodejs implementation to obtain smtp password from signed secret key for AWS SES using node/crypto
const c = require('crypto');
const utf8 = require('utf8');
const key = 'YOUR_SECRET_KEY';
const region = 'us-east-1';
const date = '11111111';
const service = 'ses';
const terminal = 'aws4_request';
const message = 'SendRawEmail';
@shrys
shrys / main.java
Last active September 12, 2019 12:46
object initialization by passing CassandraRow using reflection
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import com.datastax.spark.connector.japi.CassandraRow;
import com.datastax.spark.connector.japi.CassandraJavaUtil;
import scala.collection.Iterator;
class main {
public main(CassandraRow row) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException,
@shrys
shrys / program.cs
Last active September 21, 2021 06:39
C# implementation to obtain smtp password from signed secret key for AWS SES
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine(GetCredential("YOUR_SECRET_KEY"));
}
private static byte[] sign(byte[] key, string value)
{
return new System.Security.Cryptography.HMACSHA256(key).ComputeHash(System.Text.Encoding.UTF8.GetBytes(value));
@shrys
shrys / index.js
Last active March 22, 2019 06:11
Create image using canvas
function measureTextBinaryMethod(context, text, fontface, min, max, desiredWidth) {
if (max - min < 1) {
return min;
}
var test = min + ((max - min) / 2); //Find half interval
context.font = test + "px " + fontface;
measureTest = context.measureText(text).width;
if (measureTest > desiredWidth) {
var found = measureTextBinaryMethod(context, text, fontface, min, test, desiredWidth)
} else {