Skip to content

Instantly share code, notes, and snippets.

View veelenga's full-sized avatar
🇺🇦
Annihilating code

Vitalii Elenhaupt veelenga

🇺🇦
Annihilating code
View GitHub Profile
require "ameba"
source = Ameba::Source.new %(
class Ameba::Internals
getter info : Info
def dump
puts info
end
end
@veelenga
veelenga / btt-enable-disable.applescript.template
Created May 16, 2019 15:42 — forked from pavloo/btt-enable-disable.applescript.template
A script to enable/disable certain keystrokes in BetterTouchTool when external keyboard connected/disconnected
tell application "BetterTouchTool"
activate
update_trigger "EAE52DEC-26DA-40DC-8BB1-62A102FE676C" json "{\"BTTEnabled\" : %d}"
update_trigger "7C3BC3BC-2B93-4674-8A5F-6697FDC6E723" json "{\"BTTEnabled\" : %d}"
end tell
@veelenga
veelenga / index.js
Created February 16, 2019 20:50
AWS HEIC to JPEG Converter
const gm = require('gm').subClass({ imageMagick: true });
const root = process.env['LAMBDA_TASK_ROOT'];
const path = process.env['PATH'];
const libPath = process.env['PATH'];
// change the Lambda Runtime to use pre-built binary
process.env['PATH'] = `${root}/bin:${path}`;
process.env['LD_LIBRARY_PATH'] = `${root}/lib:${libPath}`;
@veelenga
veelenga / imagemagick.bash
Last active May 17, 2022 23:43 — forked from bensie/imagemagick.bash
ImageMagick Static Binaries with HEIC support for AWS Lambda
#!/usr/bin/env bash
# Must be run on an Amazon Linux AMI that matches AWS Lambda's runtime which can be found at:
# https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html
#
# As of Jan 10, 2019, this is:
# Amazon Linux AMI 2017.03.1.20170812 x86_64 HVM GP2 (ami-4fffc834)
#
# Lambda includes ImageMagick 6.7.8-9 preinstalled, so you need to prepend PATH
# with the folder containing these binaries in your Lambda function to ensure
@veelenga
veelenga / root.cr
Last active September 7, 2018 10:42
require "big/big_rational"
def root(n, acc = BigRational.new(2))
base = ->(n : BigRational) { 2 + n.inv }
n.times { acc = base.call(acc) }
1 + acc.inv
end
puts (1..999).map { |n| root(n) }.map { |r| [r.numerator.digits.size, r.denominator.digits.size] }.count { |(n, d)| n > d }

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@veelenga
veelenga / best_shards.cr
Last active December 8, 2018 21:57
Top 30 Shards created in 2017
require "http/client"
require "json"
module GithubAPI
API_URL = "https://api.github.com"
class Repo
JSON.mapping(
name: String,
html_url: String,
@veelenga
veelenga / send.cr
Last active March 9, 2024 18:00
Implementation of send method in Crystal using macros and procs. Just a proof of concept.
class Object
macro inherited
@@methods = {} of String => Proc({{@type}}, Nil)
macro method_added(method)
\{% if method.visibility == :public %}
%key = \{{ method.name.stringify }}
@@methods[%key] = ->(obj : \{{@type}}) {
obj.\{{ method.name }}()
nil
@veelenga
veelenga / pre-commit
Created April 20, 2017 08:00
Git pre-commit hook to format Crystal code
#!/bin/sh
crystal tool format --check &> /dev/null
ret_code=$?
if [ 0 -ne $ret_code ]; then
crystal tool format
echo "Files formatted. Please review results and commit ;)"
exit $ret_code
else
@veelenga
veelenga / rails_rce.rb
Created February 27, 2017 11:28 — forked from postmodern/rails_rce.rb
Proof-of-Concept exploit for Rails Remote Code Execution (CVE-2013-0156)
#!/usr/bin/env ruby
#
# Proof-of-Concept exploit for Rails Remote Code Execution (CVE-2013-0156)
#
# ## Advisory
#
# https://groups.google.com/forum/#!topic/rubyonrails-security/61bkgvnSGTQ/discussion
#
# ## Caveats
#