Skip to content

Instantly share code, notes, and snippets.

View touzoku's full-sized avatar
🗼

Marat Vyshegorodtsev touzoku

🗼
View GitHub Profile
import {
Stack,
StackProps,
RemovalPolicy,
aws_rds as rds,
aws_ec2 as ec2,
custom_resources as cr,
CfnResource,
} from 'aws-cdk-lib'
import { Construct } from 'constructs'
@touzoku
touzoku / plugin.js
Last active March 2, 2020 05:23
Parcel plugin that extracts classes from an HTML asset and appends CSS comment to the main CSS bundle
// @flow
import PostHTML from 'posthtml'
import type {PostHTMLNode} from 'posthtml'
import HTMLTransformer from '@parcel/transformer-html'
import type {
MutableAsset,
TransformerResult,
Transformer as TransformerOpts,
} from '@parcel/types'
@touzoku
touzoku / ducky_code.txt
Created April 3, 2019 04:37
Rubber Ducky code that works on Macs with multiple keyboards
REM Hits ⌘+Space then Ctrl+Space then 英数 button (HID 145)
REM Guarantees Spotlight open and English keyboard
REM Must use Ducky encoder with HID command support
REM https://github.com/mame82/USB-Rubber-Ducky/tree/USB-HID-keycode
DELAY 1000
GUI SPACE
CTRL SPACE
HID 145
STRING terminal
DELAY 500
@touzoku
touzoku / hiragana-pwd-generator.py
Created February 21, 2016 19:13
Generates a password in Hiragana
# -*- coding: utf-8 -*-
from random import SystemRandom
import sys
chars = list(u"ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをん")
length = int(sys.argv[1])
vocab = len(chars)
cryptogen = SystemRandom()
@touzoku
touzoku / elastic_lb.rb
Last active December 1, 2015 07:04
WIP AWS ELB resource
include Opscode::Aws::Elb
action :register do
converge_by("add the node to ELB #{new_resource.elb_name}") do
target_lb = elb.describe_load_balancers[:load_balancer_descriptions].find { |lb| lb[:load_balancer_name] == new_resource.elb_name }
unless target_lb[:instances].detect { |instances| instances.include?(instance_id) }
Chef::Log.info("Adding node to ELB #{new_resource.elb_name}")
elb.register_instances_with_load_balancer(load_balancer_name: new_resource.elb_name, instances: [{ instance_id: instance_id }])
else
Chef::Log.debug("Node #{instance_id} is already present in ELB instances, no action required.")
commands:
00_download_jdk7:
command: wget --no-cookies --no-check-certificate --header "Cookie:gpw_e24=xxx;oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u80-b15/jdk-7u80-linux-x64.rpm" -O /etc/tomcat7/jdk7-oracle.rpm
test: test ! -f /etc/tomcat7/oracle-jdk7-installed.txt
01_install_oracle_jdk7:
command: yum -y install jdk7-oracle.rpm
cwd: /etc/tomcat7
test: test ! -f /etc/tomcat7/oracle-jdk7-installed.txt && md5sum -c - <<<"b516630a940d83b066cf1e6479ec59fe jdk7-oracle.rpm"
@touzoku
touzoku / bruteforce.pl
Created September 30, 2013 03:02
Silly Japanese homework bruteforce tool
use feature 'say';
my $NUMCARDS = $ARGV[0]*2;
die "Usage: perl bruteforce.pl [NUMBER OF CARDS]\n" unless $ARGV[0];
say "num cards: $NUMCARDS";
my @init = split'','.'x$NUMCARDS;
&iterate_desc($NUMCARDS/2,@init);
@touzoku
touzoku / smileys.pl
Created January 30, 2013 13:39
Problem solution for "Balanced smileys" at Facebook Hacker Cup 2013 Qualification round. https://www.facebook.com/hackercup/problems.php?pid=403525256396727&round=185564241586420
use strict;
use warnings;
use 5.10.00;
my $regexp = qr/
^(
(?:
[a-z :]|:\(|:\)|\((?1)\)
)*
@touzoku
touzoku / beautiful.pl
Created January 30, 2013 13:37
Beautiful strings problem solution. Didn't pass for some reason. https://www.facebook.com/hackercup/problems.php?pid=475986555798659&round=185564241586420
use strict;
use warnings;
use 5.10.00;
<>;
my $case;
for(<>){
$case++;
chomp;
my(%c,$answer);
@touzoku
touzoku / ebay.sql
Last active December 10, 2015 13:49
crawler
CREATE OR REPLACE FUNCTION new_peer(n character varying, r bigint, c bigint, tp integer, lp integer)
RETURNS bigint AS
$BODY$
DECLARE peerid bigint;
BEGIN
LOOP
-- first try to update the key
UPDATE peers INTO peerid SET lastpage=lp WHERE "name" = n returning id;
IF found THEN
-- SELECT id into peerid from peers where "name"=n;