Skip to content

Instantly share code, notes, and snippets.

View andredublin's full-sized avatar
🐝
buzz

Andre Dublin andredublin

🐝
buzz
View GitHub Profile
@andredublin
andredublin / aoc2022day1.clj
Last active December 3, 2022 03:14
aoc 2022
(defn parse-int [s] (Integer/parseInt s))
(defn chunk-lines-by-blank
"Given a seq of lines, assumes that chunks of lines are separated by a blank line
(a line containing only white space) and returns a seq of those chunks
(with each chunk being its own seq of lines)"
[lines]
(->> lines
(partition-by clojure.string/blank?)
(filter (fn [c]
@andredublin
andredublin / dependency_inject.php
Created August 22, 2012 18:13
dependency injection in php/codeigniter
<?php
class BASE_Model extends CI_Model
{
/**
* inject_class - load class using dependency injection
*
* @access public
* @param string $path
* @param string $class
* @param string $func
@andredublin
andredublin / adventofcode.fs
Created December 1, 2020 18:56
Advent of code 2020
Day 1
let solve () =
let list = File.ReadLines("input.txt") |> Seq.map (fun str -> (int str)) |> Seq.toArray
let rec loop n rest=
let found = list |> Array.tryFind(fun value -> value + n = 2020)
if found.IsSome then printfn "%A" (found.Value * n)
else loop (Array.head rest) (Array.tail rest)
loop (Array.head list) (Array.tail list)

Keybase proof

I hereby claim:

  • I am andredublin on github.
  • I am andredublin (https://keybase.io/andredublin) on keybase.
  • I have a public key ASCmneb3G-wIRxvTJH_HrAePCcaMOjhaWHvjbWEcCdBWNAo

To claim this, I am signing this object:

Paket version 5.194.0
Starting full restore process.
Performance:
- Disk IO: 1 minute, 1 second
- Runtime: 1 minute, 7 seconds
This runner is now obsolete with FAKE 5, please upgrade to the new .Net Core runner. See https://fake.build/fake-migrate-to-fake-5.html
To remove this warning you can append the '--removeLegacyFakeWarning' argument or set the 'FAKE_NO_LEGACY_WARNING' environment variable to 'true'
Building project with version: LocalBuild
Shortened DependencyGraph for Target Build:
<== Build
pragma solidity ^0.4.23;
import "./Ownable.sol";
contract MyToken is Ownable {
/* This creates an array with all balances */
mapping (address => uint256) public balanceOf;
/* Initializes contract with initial supply tokens to the creator of the contract */
constructor(uint256 initialSupply) public {
@andredublin
andredublin / MyToken.sol
Created May 10, 2018 00:32
MyToken.sol with multlple agents
pragma solidity ^0.4.23;
import "./Ownable.sol";
contract MyToken is Ownable {
mapping (address => bool) public agents;
modifier onlyAgent {
require(agents[msg.sender]);
_;
@andredublin
andredublin / Agent.sol
Last active May 10, 2018 00:28
solidity agent pattern
pragma solidity ^0.4.23;
import "./MyToken.sol";
contract Agent {
MyToken token;
constructor(MyToken _token) public {
token = _token
}
@andredublin
andredublin / gist:3752002
Created September 19, 2012 20:22
Skype-Style Firewall Busting with Ruby and UDP
# From
# http://www.rubyinside.com/skype-style-firewall-busting-with-ruby-and-udp-399.html
require 'socket'
remote_host = ARGV.first
# Punches hole in firewall
punch = UDPSocket.new
punch.bind('', 6311)
@andredublin
andredublin / genesis_public_key
Created February 21, 2018 15:03
genesis_public_key
0421c428d473707698cd53e2300b0b6b49a375dd0e440a77056ef9b43263e66239e7afceec154885ad30caaafd977cf4649cc1e07f5d809bcacb5a81b41773d17a