Skip to content

Instantly share code, notes, and snippets.

View LuanVSO's full-sized avatar

Luan Vitor Simião Oliveira LuanVSO

View GitHub Profile
@skyline75489
skyline75489 / prompt.sh
Last active September 22, 2020 02:34
Windows Terminal OSC 7 for Git Bash
__wt_osc7 () {
_win_path="$(cygpath -m $(pwd))"
printf "\033]7;file://%s/%s\033\\" "$HOSTNAME" "$_win_path"
}
[ -n "$BASH_VERSION" ] && [ -n "$WT_SESSION" ] && PROMPT_COMMAND="__wt_osc7"
@skyline75489
skyline75489 / prompt.ps1
Last active December 17, 2020 10:19
Windows Terminal OSC 9;9 for PowerShell
function prompt {
$p = $($executionContext.SessionState.Path.CurrentLocation)
$converted_path = Convert-Path $p
$ansi_escape = [char]27
"PS $p$('>' * ($nestedPromptLevel + 1)) ";
Write-Host "$ansi_escape]9;9;$converted_path$ansi_escape\"
}
@skyline75489
skyline75489 / prompt.sh
Last active December 18, 2022 08:44
Windows Terminal OSC 9;9 for Bash & Zsh in WSL
__wt_osc9_9 () {
_win_path=$(wslpath -m $(pwd))
printf "\033]9;9;%s\033\\" "$_win_path"
}
[ -n "$BASH_VERSION" ] && [ -n "$WT_SESSION" ] && PROMPT_COMMAND="__wt_osc9_9"
[ -n "$ZSH_VERSION" ] && [ -n "$WT_SESSION" ] && precmd_functions+=(__wt_osc9_9)
true
@rbeesley
rbeesley / ansi-color.cmd
Last active July 10, 2022 20:20
Inspired by Daniel Crisman's BASH script from http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html. This file echoes a bunch of color codes to the terminal to demonstrate how they will render. The `Data Segment` portion of the file defines the table layout and allows the user to configure whatever matrix of ANSI Escape Sequence control characte…
@ECHO OFF & :: ANSI-COLOR :: Authored by Ryan Beesley :: https://github.com/rbeesley
GOTO :DEFINE_MACROS
%=- Entry point after macro definitions -=%
:MAIN
SETLOCAL ENABLEDELAYEDEXPANSION
CALL :PARSE_ARGS %1 %2 %3 %4 %5 %6 %7 %8 %9
:: Error when parsing
IF ERRORLEVEL 1 %@exit% %ERRORLEVEL%
:: Parsing success
@thomasvn
thomasvn / radix.c
Last active November 10, 2020 19:06
Radix Sort Implementation using C
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <time.h>
#include <math.h>
#define r 10
// ----------------------------------------------------------------------
// ------------------------- DEQUE CLASS --------------------------------
// ----------------------------------------------------------------------
@alexshtf
alexshtf / constexpr_sqrt.cpp
Last active June 7, 2023 11:19
Constexpr version of c++ square root (for doubles)
#include <limits>
namespace Detail
{
double constexpr sqrtNewtonRaphson(double x, double curr, double prev)
{
return curr == prev
? curr
: sqrtNewtonRaphson(x, 0.5 * (curr + x / curr), curr);
}
@stanislaw
stanislaw / utf8.c
Created November 19, 2015 23:09
Some C functions to work with UTF-8 string : you can check if a string is valid UTF-8, get the length of a UTF-8 string and replace things in a UTF-8 string. All `char *` arguments must be regular, null-byte terminated, C strings. I've tried to optimize the best I could. I'd be grateful for any suggestions or improvements. Please note I have onl…
//
// utf8.c
// training
//
// Created by Conrad Kleinespel on 5/27/13.
// Copyright (c) 2013 Conrad Kleinespel. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],