Skip to content

Instantly share code, notes, and snippets.

View Songbird0's full-sized avatar

Bobbywan-Roboyo Songbird0

  • France
View GitHub Profile
#[macro_use]
extern crate nom;
use std::fmt::Write;
fn get_all_a(input: &[u8]) -> nom::IResult<&[u8], Vec<&[u8]>, u32> {
let io: (&[u8], Vec<&[u8]>) = {
let mut a_list: Vec<&[u8]> = vec!();
let mut current_input: &[u8] = &b""[..];
let input_length = input.len();
# -*-coding: utf-8 -*-
# B la base de points du niveau actuel
# N = 19, le nombre de niveaux
# P, les points obtenus à l'instant T
# J, le nombre de jours de présence potentiellement effectués
# dans le futur.
# U, le facteur multiplicateur activé si l'utilisateur a assisté à la dernière réunion.
# C, le coefficient de proportionnalité commun à chaque base (B).
# R (inconnue), le nombre de jours restants à jouer pour être promu.
#
@Songbird0
Songbird0 / project_wrapper.rs
Created April 12, 2018 21:37
Somewhat theorical draft
extern crate toml;
#[macro_use]
extern crate serde_derive;
macro_rules! generate_struct {
($struct_name:ident, $( $property_name:ident, $property_type:ty ),*) => (
use std::fmt::Debug;
#[derive(Debug)]
struct $struct_name {
$(
@Songbird0
Songbird0 / treegenerator.html
Created December 7, 2017 22:33
Dirty draft
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body ng-app="Foo" ng-controller="Controller">
<tree-generator tree-title="pwet" sections="['bar', 'baz', 'bang']"></tree-generator>
<script>
# -*- coding: utf-8 -*-
# Std
import unittest
# Third party
# Internal
@Songbird0
Songbird0 / create_relative_path.py
Created November 30, 2017 19:52
CheatSheet: Create a relative path from an absolute or another relative path.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import pathlib
def create_relative_path(initial_path: pathlib.Path, new_root: str) -> pathlib.Path:
"""Creates a new path from the initial path.
Example:
your_path = pathlib.Path('/foo/bar/baz/bang')
@Songbird0
Songbird0 / get_a_zip_in_response.py
Created November 19, 2017 20:40
Django cheatsheet N°1
# Python version: 3.6.3
# See docs:
# * https://docs.djangoproject.com/en/1.11/ref/request-response/#django.http.HttpResponse
# * https://docs.djangoproject.com/en/1.11/ref/request-response/#httprequest-objects
# * https://docs.python.org/3/library/io.html?highlight=io%20bytesio#io.BytesIO
def zipfile_gen(request: django.http.HttpRequest) -> django.http.HttpResponse:
import pathlib
import io
text_file = pathlib.Path(__file__).parent / 'a_text_file.txt'
buffer = io.BytesIO()
@Songbird0
Songbird0 / tagrplc.rs
Last active August 26, 2017 01:16
(personal draft) tag replacing
const INLINE_TAG: &'static str = "[inline]";
const CLOSED_INLINE_TAG: &'static str = "[/inline]";
fn main() {
let raw_input = "`hello`";
let couple = (INLINE_TAG, CLOSED_INLINE_TAG);
let delimiter = "`";
let wrapped_content = wrap_with_couple_of_tag(raw_input.to_owned(), couple, delimiter);
assert_eq!(wrapped_content, "[inline]hello[/inline]");
@Songbird0
Songbird0 / split.rs
Created October 2, 2016 00:23
straight to point split function
fn split(chaine: String) -> Vec<String>
{
let lettres = chaine.chars();
let mut newChaine : Vec<String> = Vec::new();
let mut buffer : String = String::new();
for lettre in lettres
{
if lettre.is_whitespace()
{
newChaine.push(buffer);
function sliceAt(initial_string, target) {
var index = initial_string.indexOf(target);
if (index !== -1) {
switch (index) {
case 0: return initial_string.substring(index + target.length);
case (initial_string.length - 1): return initial_string.substring(index, target.length - 1);
}
var first_part = '';
var second_part = '';
first_part = initial_string.substring(0, index);