Skip to content

Instantly share code, notes, and snippets.

View marianposaceanu's full-sized avatar

Posăceanu Marian marianposaceanu

View GitHub Profile
@marianposaceanu
marianposaceanu / disable.sh
Created December 31, 2019 00:04
Disable bunch of #$!@ in Catalina
#!/bin/bash
# IMPORTANT: Don't forget to logout from your Apple ID in the settings before running it!
# IMPORTANT: You will need to run this script from Recovery. In fact, macOS Catalina brings read-only filesystem which prevent this script from working from the main OS.
# This script needs to be run from the volume you wish to use.
# E.g. run it like this: cd /Volumes/Macintosh\ HD && sh /Volumes/Macintosh\ HD/Users/sabri/Desktop/disable.sh
# WARNING: It might disable things that you may not like. Please double check the services in the TODISABLE vars.
# Get active services: launchctl list | grep -v "\-\t0"
# Find a service: grep -lR [service] /System/Library/Launch* /Library/Launch* ~/Library/LaunchAgents
@marianposaceanu
marianposaceanu / capybara cheat sheet
Created August 29, 2016 12:55 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@marianposaceanu
marianposaceanu / ElCapitan.applescript
Created February 17, 2016 00:35 — forked from nrollr/ElCapitan.applescript
Performance improvements for El Capitan
-- Disable Time Machine Local Backups
sudo tmutil disablelocal
-- Disable Automatic Spell Checker
defaults write -g NSAutomaticSpellingCorrectionEnabled -bool false
-- Disable animations when opening and closing windows.
defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false
-- Disable animations when opening a Quick Look window.
defaults write -g QLPanelAnimationDuration -float 0
-- Accelerated playback when adjusting the window size (Cocoa applications).
defaults write NSGlobalDomain NSWindowResizeTime -float 0.001
#!/bin/bash -ex
### More info: https://coderwall.com/p/a56j3w/memory-efficient-ubuntu-vms
### configuration
PKGS_TO_ADD="$PKGS_TO_ADD curl git etckeeper python-software-properties"
PKGS_TO_REMOVE="$PKGS_TO_REMOVE geoip-database popularity-contest"
PKGS_TO_REMOVE="$PKGS_TO_REMOVE pppoeconf pppconfig ppp"
PKGS_TO_REMOVE="$PKGS_TO_REMOVE ubuntu-standard memtest86+" # warning: be careful about what you remove after this
task :ask_production_confirmation do
set(:confirmed) do
puts <<-WARN
========================================================================
WARNING: You're about to perform actions on production server(s)
Please confirm that all your intentions are kind and friendly
========================================================================
{
# First, we need to add an empty key/value tuple (just an empty fork) to this `execution`, in preperation for
# making a `locals` list to store variables on.
#
# ┌ - we have to assume that native juxtaposition of `infrastructure` against the root-level `execution` will
# │ somehow “fall through.” I haven’t yet figured out the semantics of Nuclear-level scoping/fall-through.
# │ - considering: if `<this> locals` nothingnesses-out, then we juxtapose against enclosing scope at the
# │ interpreter level (which would imply, at this root scope, juxtaposing against the global scope I suppose)
# │
# │ ┌ - no `call()` implemented at this level, so we have to assume that the native-default juxtaposition for
@marianposaceanu
marianposaceanu / arel mapped template ids.rb
Created December 21, 2013 00:12 — forked from ndbroadbent/arel mapped template ids.rb
Using Arel instead of ActiveRecord
module Sq
class Template < Sequel::Model
one_to_many :fields
def mapped_template_ids
FieldMapping.as(:m).
join(Field.named(:f), id: :field_id, template_id: id).
join(Field.named(:mf), id: :m__mapped_field_id).
distinct.select_map(:mf__template_id)
end
module KawaiiPhrase
# Makes awesome random phrases such as "Enjoyable Green Turtle"
ADJ_1 = [
'epic',
'tasty',
'shiny',
'mega',
'ultra',
'hyper',

Upgrade sha1 => scrypt without user logging in/pw reset:

μBackground:

We hash passwords with one-way hash functions to reduce the impact of password database compromise. Passwords hashed with salted SHA or MD5 can ofen be brute forced. Newer password hashhing techniques like Scrypt/Bcrypt/PBKDF2 add computational work to make brute forcing prohibitively expensive.

Problem:

Your service already has users with salted sha1 password hashes. Since you don't have their original passwords you can't upgrade to a modern password hash without getting each user to log in and enter their password.

You have (salt,sha(salt+password)), you want (salt, scrypt(salt,password))

#!/usr/bin/env ruby
#------------------------------------------------------------------------------
# Aggregate Print useful information from /proc/[pid]/smaps
#
# pss - Roughly the amount of memory that is "really" being used by the pid
# swap - Amount of swap this process is currently using
#
# Reference:
# http://www.mjmwired.net/kernel/Documentation/filesystems/proc.txt#361