Skip to content

Instantly share code, notes, and snippets.

View vesan's full-sized avatar

Vesa Vänskä vesan

View GitHub Profile
@vesan
vesan / Gemfile
Created September 19, 2020 18:52 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@vesan
vesan / useQuery.js
Created May 6, 2020 11:57
Sync URL with state using react-router
// Usage: const [filters, setFilters] = useQuery(useState({}));
import { useHistory, useLocation } from "react-router-dom";
export default function useQuery([defaultQuery, setValue], method = "push") {
const history = useHistory();
const { search, pathname, hash } = useLocation();
const hasParams = search.indexOf("=") > -1;
const setValueWithQuery = (newQuery) => {
setValue((state) => {
{
"ipcMode": null,
"executionRoleArn": "arn:aws:iam::<aws-account-number>:role/ecsTaskExecutionRole",
"containerDefinitions": [
{
"dnsSearchDomains": [],
"logConfiguration": {
"logDriver": "awslogs",
"secretOptions": [],
"options": {
@vesan
vesan / ruby-ldap-sample.rb
Created November 14, 2019 14:51 — forked from jeffjohnson9046/ruby-ldap-sample.rb
Some VERY basic LDAP interaction in Ruby using Net::LDAP.
#######################################################################################################################
# This Gist is some crib notes/tests/practice/whatever for talking to Active Directory via LDAP. The (surprisingly
# helpful) documentation for Net::LDAP can be found here: http://net-ldap.rubyforge.org/Net/LDAP.html
#######################################################################################################################
require 'rubygems'
require 'net/ldap'
#######################################################################################################################
# HELPER/UTILITY METHOD
// Synchronous
use std::{
collections::HashMap,
error::Error,
fs::File,
io::{prelude::*, BufReader},
};
fn main() -> Result<(), Box<dyn Error>> {
let file = BufReader::new(File::open("top100.txt")?);
@vesan
vesan / factory_doctor.rb
Created August 6, 2017 09:53 — forked from palkan/factory_doctor.rb
FactoryDoc: detect useless data generation in tests
module FactoryGirl
module Doctor
module FloatDuration
refine Float do
def duration
t = self
format("%02d:%02d.%03d", t / 60, t % 60, t.modulo(1) * 1000)
end
end
end
@vesan
vesan / Rails Console Actionmailer test.rb
Last active August 22, 2016 08:49 — forked from tansengming/Rails Console Actionmailer test.rb
Rails Console Actionmailer test
# Copy and paste this to the rails console to test your email settings
class MyMailer < ActionMailer::Base
def test_email
@recipients = "vesa@kiskolabs.com"
@from = "must_be_same_as_smpt_account_login@gmail.com"
@subject = "Test from the Rails Console"
@body = "This is a test email"
end
end
@vesan
vesan / routes.rake
Created August 22, 2016 07:25
Journey + Graphviz
namespace :routes do
desc "Writes doc/routes.html. Requires Graphviz (dot)"
task :visualizer => :environment do
File.open(Rails.root.join('doc', 'routes.html'), 'wb') do |f|
f.write Rails.application.routes.router.visualizer
end
end
end
@vesan
vesan / amzn_wish_list_transfer.rb
Last active November 18, 2015 21:46 — forked from polarblau/amzn_wish_list_transfer.rb
Transferring Amazon wish list entries the hard way between international stores.
#!/usr/bin/env ruby
require "rubygems"
require "mechanize"
TARGET_LOGIN_URL = "https://www.amazon.com/ap/signin?_encoding=UTF8&openid.assoc_handle=usflex&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.com%2Fgp%2Fcss%2Fhomepage.html%3Fie%3DUTF8%26*Version*%3D1%26*entries*%3D0%26ref_%3Dnav_signin"
SOURCE_LOGIN_URL = "https://www.amazon.co.uk/ap/signin?_encoding=UTF8&openid.assoc_handle=gbflex&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions
require "faraday"
require "faraday_middleware"
require "pp"
connection = Faraday.new 'http://api.hel.fi/linkedevents/v0.1/' do |conn|
conn.response :json, :content_type => /\bjson$/
conn.adapter Faraday.default_adapter
end