Skip to content

Instantly share code, notes, and snippets.

@detunized
detunized / fetch-github-activity.rb
Created April 18, 2019 11:31
Fetch GitHub activity from your profile page
require "open-uri"
def github_activity username
open("https://github.com/#{username}") { |io| io.read }
.scan(/fill="#(.{6})" data-count="(\d+)"/)
.map { |i| {color: i[0], value: i[1].to_i} }
end
p github_activity "your-username"
@detunized
detunized / enable-exit-pulse-secure.sh
Created April 17, 2019 12:12
Enable exit function in Pulse Secure (when disabled by the admin)
# /bin/bash
cd '/Library/Application Support/Pulse Secure/Pulse'
sudo sed -i '' \
s'/connection-policy-override: "false"/connection-policy-override: "true"/' \
connstore.dat
sudo killall PulseTray 'Pulse Secure' dsAccessService
@detunized
detunized / find-code.cs
Created March 16, 2019 21:02
Find a code pattern in C# files
// Copyright (C) 2019 Dmitry Yakimenko ([email protected]).
// Licensed under the terms of the MIT license. See LICENCE for details.
using System;
using System.IO;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@detunized
detunized / nunut2xunit.cs
Created March 12, 2019 23:23
Convert NUnit to xUnit
// Copyright (C) 2019 Dmitry Yakimenko ([email protected]).
// Licensed under the terms of the MIT license. See LICENCE for details.
using System;
using System.IO;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@detunized
detunized / index.js
Last active March 1, 2019 21:41
JavaScript solutions profiling
#!/usr/bin/env node --expose-gc
//
// Logest word
//
function findLongestWordLengthForLoop(str) {
let maxVal = 0;
const wordArr = str.split(' ');
@detunized
detunized / join.sh
Last active March 6, 2024 20:09
Join repos into subfolders with flat history
#!/bin/bash
set -euo pipefail
$REPO_DIR=~/devel
repos="1password bitwarden dashlane lastpass opvault passwordbox roboform stickypassword truekey zoho-vault"
# pull all repos
(
for repo in $repos; do
echo $repo
@detunized
detunized / t2b.rb
Last active June 13, 2018 08:34
Naive t2b (https://github.com/thosakwe/t2b) implementation proof of concept
#!/usr/bin/env ruby
#
# DSL implementation
#
$stack = [""]
def emit x
$stack.last << x
@detunized
detunized / find-lib.rb
Created January 18, 2018 10:17
Find which library (.a or .so) exports a symbol
#!/usr/bin/env ruby
begin
require "parallel"
PARALLEL = true
rescue LoadError
PARALLEL = false
end
def each collection, &block
@detunized
detunized / leetcode-91-decode-ways.rb
Created January 7, 2018 18:34
LeetCode problem #91: Decode ways
# @param {String} s
# @return {Integer}
def num_decodings(s)
return 0 if s.empty?
n1 = 1
n2 = 0
i = 0
while i < s.size
@detunized
detunized / join-onpama-repos.sh
Created December 26, 2017 15:06
Join a bunch of repos into subfolders and rewrite the history to reflect where the commits are coming from
#!/bin/bash
set -e
# Clone repos locally into original/
(
mkdir original
cd original
git clone [email protected]:detunized/lastpass-sharp.git