Skip to content

Instantly share code, notes, and snippets.

View malzzz's full-sized avatar

Mallory M. malzzz

  • Asymmetric Finance
  • /dev/null
View GitHub Profile
@RxDx
RxDx / MacOSLogoutHook.txt
Last active September 21, 2023 23:50
MacOS: Run script before shutdown
Create a file:
$ pico /Users/Shared/logoutHook.sh
File content:
#!/bin/bash
say 'Hasta la vista baby!'
Set exuction permission:
$ sudo chmod +x /Users/Shared/logoutHook.sh
@Glamdring
Glamdring / EthereumService.java
Last active August 1, 2018 15:36
Sample EthereumJ transaction sending
package com.mypackage.ethereumsync;
import java.io.File;
import java.math.BigInteger;
import java.util.Base64;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
@tomw1808
tomw1808 / send_transfer_call.sol
Last active December 6, 2018 08:46
This is an example of the difference between "address.send()", "address.call.value()()" and "address.transfer()" in Solidity. If you like this example, then checkout my courses I do on Udemy (https://vomtom.at/tag/course/)
pragma solidity ^0.4.13;
contract someContract {
mapping(address => uint) balances;
function deposit() payable {
balances[msg.sender] += msg.value;
}
@bitnenfer
bitnenfer / index.html
Last active September 1, 2022 16:18
wasm binary loader with fallback to asm.js
<!DOCTYPE html>
<html>
<head>
<title>LOADING...</title>
</head>
<body>
<script type="text/javascript">
window.onload = function () {
extern crate futures;
extern crate futures_cpupool;
extern crate rand;
use futures::{Future, Sink, Stream};
/// Sleep for a random time between 0 and 1 second.
fn sleep_random() {
let sleep_time_ms = rand::random::<u8>() as f64 / 255.0 * 1000.0;
std::thread::sleep(std::time::Duration::from_millis(sleep_time_ms as u64));
@KodrAus
KodrAus / Profile Rust on Linux.md
Last active November 14, 2023 17:19
Profiling Rust Applications

Profiling performance

Using perf:

$ perf record -g binary
$ perf script | stackcollapse-perf.pl | rust-unmangle | flamegraph.pl > flame.svg

NOTE: See @GabrielMajeri's comments below about the -g option.

Revisiting Tagless Final Interpreters

Tageless Final interpreters are an alternative to the traditional Algebraic Data Type (and generalized ADT) based implementation of the interpreter pattern. This document presents the Tageless Final approach with Scala, and shows how Dotty with it's recently added implicits functions makes the approach even more appealing. All examples are direct translations of their Haskell version presented in the Typed Tagless Final Interpreters: Lecture Notes (section 2).

The interpreter pattern has recently received a lot of attention in the Scala community. A lot of efforts have been invested in trying to address the biggest shortcomings of ADT/GADT based solutions: extensibility. One can first look at cats' Inject typeclass for an implementation of [Data Type à la Carte](http://www.cs.ru.nl/~W.Swierstra/Publications/DataTypesA

@oliver-batchelor
oliver-batchelor / Tensor.hs
Last active October 2, 2016 23:55
Attempts at static tensor dimensioning
{-# LANGUAGE TemplateHaskell, FlexibleContexts, FlexibleInstances, GADTs, DataKinds,
TypeInType, KindSignatures, InstanceSigs, TypeOperators,
ConstraintKinds, RankNTypes, ScopedTypeVariables, TypeFamilies,
UndecidableInstances, MultiParamTypeClasses, TypeApplications, PartialTypeSignatures #-}
--{-# OPTIONS_GHC -fplugin GHC.TypeLits.Normalise -fplugin GHC.TypeLits.KnownNat.Solver #-}
-- Three attempts at implementing a 'concat' operation for arbitrary dimension tensors,
-- concat dim xs ys is valid only if tensor xs and tensor ys share the same shape
-- (except for the dimension being joined)

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@torao
torao / WebSocketClient.scala
Created August 23, 2016 12:59
WebSocket Client Example for Scala 2.11 with Netty 4
// WebSocket Client Example for Scala 2.11 with Netty 4
// http://netty.io/4.0/xref/io/netty/example/http/websocketx/client/WebSocketClient.html
package org.koiroha.websocket
import io.netty.bootstrap.Bootstrap
import io.netty.buffer.Unpooled
import io.netty.channel.{Channel,ChannelFuture,ChannelHandlerContext,ChannelInitializer,ChannelPipeline,ChannelPromise,EventLoopGroup,SimpleChannelInboundHandler}
import io.netty.channel.nio.NioEventLoopGroup
import io.netty.channel.socket.SocketChannel
import io.netty.channel.socket.nio.NioSocketChannel