Skip to content

Instantly share code, notes, and snippets.

View apiraino's full-sized avatar

apiraino

View GitHub Profile
### install deps
Reference here: https://medium.com/@ianjsikes/get-started-with-rust-webassembly-and-webpack-58d28e219635
### create a binary rust project
### write a public function
### compile Rust code targeting WASM
wargo build (i.e. cargo build --target=wasm32-unknown-emscripten)
### test binary
@apiraino
apiraino / pwd_exporter.py
Created January 23, 2018 21:19
Convert XML file from Firefox (pre-Quantum) extension --> Keepass import CSV
#!/usr/bin/env python3
# Convert XML file from the firefox (pre-Quantum) extension
# into a CSV suitable to be imported into keepassxc
# Notes:
# - Python3 only!
# - password must be exported in plain text
# - requires defusedxml package ("pip install defusedxml")
@apiraino
apiraino / TCP sync forwarder
Last active April 10, 2018 20:23
TCP sync forwarder
extern crate encoding;
use std::io::prelude::*;
use std::io::{BufReader, BufWriter};
use std::env;
use std::net::{Shutdown, TcpStream};
use encoding::{EncoderTrap, Encoding};
use encoding::all::ASCII;
fn main() {
#![deny(warnings)]
extern crate tokio;
extern crate tokio_io;
use std::sync::{Arc, Mutex};
use std::net::{Shutdown, SocketAddr};
use tokio::net::{TcpListener, TcpStream};
use tokio::prelude::*;
@apiraino
apiraino / gist:8fd8bbbe797ec12fe8dd2bd3a3f2d8f8
Created July 12, 2018 00:39
Langenscheidt OpenSearch description file
// Create these files on a webserver (also localhost is ok) and point your browser there
// Reference: https://developer.mozilla.org/en-US/docs/Web/OpenSearch
// lg.html
<html lang="en-US" dir="ltr" class="no-js">
<head prefix="og: http://ogp.me/ns#">
<meta charset="utf-8">
<link rel="search" type="application/opensearchdescription+xml" href="/lg_osd.xml" title="Langenscheidt Ita-Deu"/>
You should see a + icon on the custom search engine box.
struct Foo {}
impl Bar for Foo {
fn dummy_spacer() -> bool {
false
}
fn dummy_spacer() -> bool {
false
}
#!/usr/bin/env bash
# set -x
# /usr/lib/gnome-settings-daemon/gsd-backlight-helper
#Application Options:
# --set-brightness Set the current brightness
# --get-brightness Get the current brightness
# --get-max-brightness Get the number of brightness levels supported
@apiraino
apiraino / gist:4c8abac8d23398b2bd6dcd5d3d54e1df
Created December 5, 2018 16:59
test case for rust-mode emacs fix
(defun rust-test-fn (code expected-result)
(with-temp-buffer
(rust-mode)
(insert code)
;; check window before formatting
(let (w-start (window-start))
(message "%s" w-start)
)
(rust-format-buffer)
(should (equal expected-result (buffer-string)))
pub struct MyStruct {
num: i32
}
impl MyStruct {
// setting to "pub", makes the warning disappear
fn new() -> MyStruct {
MyStruct { num : 2 }
}
⚠️
:warning:
### hey
#### hey 2