Skip to content

Instantly share code, notes, and snippets.

View Krelix's full-sized avatar

Adrien Brizard Krelix

View GitHub Profile
@Krelix
Krelix / main.rs
Last active May 13, 2016 15:11
[Intermediate] /r/dailyprogrammer challenge 266
use std::collections::BTreeMap;
// char to usize
fn parse_int(str: String) -> usize {
str.chars().fold(0, |val, c| (val*10 + (c.to_digit(10).unwrap()) as usize))
}
fn read_input(filename: &str) -> String {
use std::io::Read;
use std::fs::File;
@Krelix
Krelix / bonus.rs
Last active May 13, 2016 10:25
Reddit Programming Challenge 266
fn bonus (input: &String) {
// input is the same as in the main.rs
let mut adj_mat:Vec<usize> = Vec::new();
let mut length = 0;
for line in input.split('\n') {
let connections: Vec<_> = line.split_whitespace().collect();
let conn_to:usize = parse_int(connections[0].to_string());
// Tabs from input not handled...
if conn_to <= 0 {
continue;
@Krelix
Krelix / ClickTimer.html
Last active August 29, 2015 14:06
Simple HTML page that register a first click and increments a timer until the mouse click is registered again on the page.
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="utf-8" />
<script type="text/javascript">
var timer;
var myTimeout;
var updateTime = function(myTime){
document.getElementById("timer").textContent = myTime;
}
@Krelix
Krelix / changePerm.ps1
Created June 30, 2014 09:32
PowerShell - Change permissions and owner of all the files and directories in the current folder.
# Don't forget to ser $usernameFull to the name off account in this format : DOMAIN\username
$rule = new-object System.Security.AccessControl.FileSystemAccessRule($usernameFull, 'FullControl', 'Allow');
$owner = new-object System.Security.Principal.NTAccount($usernameFull)
foreach($file in $(Get-ChildItem ./ -recurse)){
$acl=get-acl $file.FullName
$acl.SetAccessRule($rule)
$acl.SetOwner($owner)
set-acl $file.FullName $acl
}
@Krelix
Krelix / mutationObserver.js
Last active September 21, 2021 20:15
Simple MutationObserver to understand the behaviour of DOM modifications for a specific AJAX library.
// Just a method to log NodeList content
var logChildrenModifications = function(type, array) {
if (array instanceof NodeList) {
for (var i = 0; i < array.length; i++) {
if (array.item(i) instanceof NodeList) {
logChildrenModifications(type, array.item(i));
} else {
console.log(type + ' ' + array.item(i).nodeName);
}
}