Skip to content

Instantly share code, notes, and snippets.

View lazywalker's full-sized avatar
💭
reborn

lazywalker

💭
reborn
View GitHub Profile
@jimmychu0807
jimmychu0807 / string-conversion.rs
Created November 21, 2019 10:20
Conversion between String, str, Vec<u8>, Vec<char> in Rust
use std::str;
fn main() {
// -- FROM: vec of chars --
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}'];
// to String
let string1: String = src1.iter().collect::<String>();
// to str
let str1: &str = &src1.iter().collect::<String>();
// to vec of byte
@Melvillian
Melvillian / gist:17d10138f616893eeb88525987c6f7d5
Last active August 12, 2023 12:05
Solutions to "move_semantics2.rs" of Rustlings
/// given this uncompilable code
pub fn main() {
let vec0 = Vec::new();
let mut vec1 = fill_vec(vec0);
// Do not change the following line!
println!("{} has length {} content `{:?}`", "vec0", vec0.len(), vec0);
vec1.push(88);
@sirkkalap
sirkkalap / tz-example.sh
Created February 23, 2015 23:17
Ways to set up Docker container's timezone
$ docker run --rm busybox date
Thu Mar 20 04:42:02 UTC 2014
$ docker run --rm -v /etc/localtime:/etc/localtime busybox date
Thu Mar 20 14:42:20 EST 2014
$ FILE=$(mktemp) ; echo $FILE ; echo -e "Europe/Brussels" > $FILE ; docker run --rm -v $FILE:/etc/timezone -v /usr/share/zoneinfo/Europe/Brussels:/etc/localtime busybox date
/tmp/tmp.JwL2A9c50i
Thu Mar 20 05:42:26 CET 2014
@SONIC3D
SONIC3D / Push_MultiDimArray.c
Created April 10, 2014 14:26
Return a multidimensional table from C function to lua
/*
Return an array in this structure
http://stackoverflow.com/questions/20173954/how-to-return-a-multidimensional-table-from-c-function-to-lua
In Lua array values usually starts at 1.
{
[1] = { ["field1"] = "1", ["field2"] = "2" , ["field3"] = "3" },
[2] = { ["field1"] = "10" , ["field2"] = "20", ["field3"] = "30" }
}
*/
@pascalpoitras
pascalpoitras / config.md
Last active June 6, 2024 13:09
My WeeChat configuration

WeeChat Screenshot

Mouse


enable


@return1
return1 / trim_enabler.txt
Last active May 26, 2024 11:01
TRIM Enabler for OS X Yosemite 10.10.3
#
# UPDATE for 10.10.4+: please consider this patch obsolete, as apple provides a tool called "trimforce" to enable trim support for 3rd party SSDs
# just run "sudo trimforce enable" to activate the trim support from now on!
#
# Original version by Grant Parnell is offline (http://digitaldj.net/2011/07/21/trim-enabler-for-lion/)
# Update July 2014: no longer offline, see https://digitaldj.net/blog/2011/11/17/trim-enabler-for-os-x-lion-mountain-lion-mavericks/
#
# Looks for "Apple" string in HD kext, changes it to a wildcard match for anything
#
# Alternative to http://www.groths.org/trim-enabler-3-0-released/