Skip to content

Instantly share code, notes, and snippets.

View squiidz's full-sized avatar

JChaput squiidz

  • Joliette
View GitHub Profile
@squiidz
squiidz / playground.rs
Created March 6, 2017 18:51 — forked from anonymous/playground.rs
Shared via Rust Playground
#[derive(Debug, PartialEq, Eq, Clone)]
struct Node<T: Clone> {
name: String,
value: T,
next: Option<Box<Node<T>>>
}
impl<T: PartialEq + Clone> Node<T> {
fn new(name: &str, value: T) -> Self {
Node {
@squiidz
squiidz / playground.rs
Created January 27, 2017 19:52 — forked from anonymous/playground.rs
Shared via Rust Playground
fn main() {
let text = "ありがとうございます";
let words = text.split("").map(|w| w.as_bytes()).collect::<Vec<&[u8]>>();
let length = words.iter().fold(0, |acc, val| acc + val.len());
println!("Input Text: {}", text);
println!("Bytes: {:?}", words);
println!("Text is {} bytes long", length);
let mut inline_bits = String::new();
@squiidz
squiidz / playground.rs
Created January 24, 2017 17:33 — forked from anonymous/playground.rs
Shared via Rust Playground
trait Entity {
fn walk(&self) -> String;
}
struct Dog {
name: String,
age: i32
}
impl Dog {
@squiidz
squiidz / main.rs
Created December 1, 2016 04:09
GMD
#![feature(exact_size_is_empty)]
use std::io::{self, Read};
use std::process::Command;
use std::env;
fn main() {
let mut entry = String::new();
if env::args().is_empty() {
match io::stdin().read_to_string(&mut entry) {
Ok(_) => {},
@squiidz
squiidz / parse.rs
Created July 9, 2016 00:13
rust_parse_string
use std::io::{self, Read};
use std::env;
#[derive(Debug)]
struct Entity {
data: String,
iter: Iterat,
}
#[derive(Debug)]
@squiidz
squiidz / jwt-example.go
Created May 24, 2015 19:31
JWT in Golang
package main
import (
"fmt"
"net/http"
"time"
"github.com/go-zoo/bone"
"github.com/go-zoo/claw"
mw "github.com/go-zoo/claw/middleware"
@squiidz
squiidz / btree.go
Last active March 16, 2016 19:26
Simple Binary tree in Go
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"math/rand"
"time"
package main
import (
"bytes"
"fmt"
"io"
)
type Maker interface {
WriteIn(data []byte) (int, error)
package main
import (
"log"
"net"
"strconv"
)
type Server struct {
Addr string
@squiidz
squiidz / Tiny TCP Server
Created November 5, 2014 16:26
Learn Go
package main
import (
"log"
"net"
)
func main() {
data := make([]byte, 1024)
list, err := net.Listen("tcp", "localhost:9000")