Skip to content

Instantly share code, notes, and snippets.

View green-coder's full-sized avatar
🌱

Vincent Cantin green-coder

🌱
View GitHub Profile
@green-coder
green-coder / RadialLayout.cs
Last active September 15, 2015 07:33 — forked from anonymous/RadialLayout.cs
Radial Layouts within Unity3Ds UI system
using UnityEngine;
using UnityEngine.UI;
/*
Radial Layout Group by Just a Pixel (Danny Goodayle) - http://www.justapixel.co.uk
Copyright (c) 2015
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px; }
body > *:first-child {
@green-coder
green-coder / main.rs
Last active September 17, 2016 19:39
struct ApplyFnToParam<F> {
f: F,
param: u32
}
fn my_default_fn(param: u32) -> bool {
param == 42
}
// This is the part which blocked me the whole day, and I finally figured it out myself.
@green-coder
green-coder / App.java
Created December 4, 2011 05:30
Example of how to parse an html file with Jsoup.
import java.io.IOException;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
public class App {
public static void main(String[] args) throws IOException {
Document doc = Jsoup.connect ("http://project2612.org/details.php?id=86").get();
Element element = doc.select("td:containsOwn(English Title) + td").first();
System.out.println("English name of the game: " + element.text());
@green-coder
green-coder / license_header_prepender.sh
Last active October 7, 2016 02:17
This prepends a header file to each matching file, recursively on the file system.
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
IFS=$'\n'
for f in $(find . -name '*.cs')
do
if ! grep -q Copyright "$f"
then
cat "$DIR"/copyright_header.txt "$f" >"$f".new && mv "$f".new "$f"
@green-coder
green-coder / C.java
Created April 9, 2017 14:27
Google Code Jam 2017, Qualification Round, compact C solution
/**
* Complexity O(log(k))
*/
private static String solve2(long n, long k) {
while (k != 1) {
n = ((n & 1) == 0 && (k & 1) == 1) ? (n / 2) - 1 : n / 2;
k = k / 2;
}
long bigHalf = n / 2;
@green-coder
green-coder / C.java
Created April 9, 2017 14:29
Google Code Jam 2017, Qualification Round, readable C solution
/**
* Complexity O(log(k))
* Terminal recursion
*/
private static String solve(long n, long k) {
if (k == 1) {
long bigHalf = n / 2;
long smallHalf = (n - 1) - bigHalf;
return "" + bigHalf + " " + smallHalf;
@green-coder
green-coder / ZenjectNetworkManager.cs
Created January 25, 2016 16:34
Zenject support for Unity Networking
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;
using System.Collections.Generic;
using Zenject;
public class ZenjectNetworkManager : NetworkManager, IInitializable {
[Inject]
DiContainer Container;
@green-coder
green-coder / 00_destructuring.md
Created January 5, 2018 01:12 — forked from john2x/00_destructuring.md
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors

@green-coder
green-coder / tree-seq.clj
Last active April 8, 2018 20:43 — forked from mfikes/tree-seq.clj
Directly-reducible PoC in Clojure
(defn nth' [coll n]
(transduce (drop n) (completing #(reduced %2)) nil coll))
(defn tree-seq'
[branch? children root]
(eduction (take-while some?) (map first)
(iterate (fn [[node pair]]
(when-some [[[node' & r] cont] (if (branch? node)
(if-some [cs (not-empty (children node))]
[cs pair]