Skip to content

Instantly share code, notes, and snippets.

@sguzman
sguzman / main.rs
Created July 1, 2018 00:28
A simple example involving raw pointers, padding, structs, byte addressing and stuff
pub fn main() {
struct Lel {
ch: char,
num: u64
}
struct Yip {
lel: Lel,
b: bool
}
@sguzman
sguzman / ffmpeg.sh
Created June 30, 2018 14:19
Create a black video with an added mp3 track
ffmpeg -s 640x480 -f rawvideo -pix_fmt rgb24 -r 25 -i /dev/zero -i music.mp3 -vcodec libx264 -preset medium -tune stillimage -crf 24 -acodec copy -shortest output.mkv
@sguzman
sguzman / main.rs
Created June 29, 2018 19:44
A simple example using html5ever to modify html data
extern crate html5ever;
use html5ever::{ParseOpts, parse_document};
use html5ever::tree_builder::TreeBuilderOpts;
use html5ever::rcdom::RcDom;
use html5ever::rcdom::NodeEnum::Element;
use html5ever::serialize::{SerializeOpts, serialize};
use html5ever::tendril::TendrilSink;
fn main() {
@sguzman
sguzman / Cmake.txt
Created June 23, 2018 07:32
A cmake build file linking to cheerp tool chain
cmake_minimum_required(VERSION 3.11)
project(out.js)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "-Wall -target cheerp")
set(CMAKE_CXX_COMPILER "/Applications/cheerp/bin/clang++")
set(CMAKE_LINKER "/Applications/cheerp/bin/llvm-link")
set(CMAKE_AR "/Applications/cheerp/bin/llvm-ar")
set(CMAKE_NM "/Applications/cheerp/bin/llvm-nm")
set(CMAKE_OBJDUMP "/Applications/cheerp/bin/llvm-objdump")
@sguzman
sguzman / extracting.rs
Created June 20, 2018 11:44
Extracting stuff from a page- may need it in the future
println!("Downloading {}", url);
let html = dom::get_html_from_path(url);
let title = dom::get_single_text(&html, "h1.post-title");
let img = {
let img = dom::get_single(&html, "div.book-cover img[src]", "src");
let img = img.trim_left_matches("https://it-eb.com");
format!("http://23.95.221.108{}", img)
};
@sguzman
sguzman / war.sh
Created May 19, 2018 06:06
This is war
nmap -vvv -p- -O -Pn -sV --version-intensity 9 -T5
@sguzman
sguzman / curl.hxx
Created April 25, 2018 07:43
Calling curl from C++
#pragma once
#include <curl/curl.h>
#include <string>
namespace Curl {
inline static const size_t CurlWrite_CallbackFunc_StdString(void *contents, const size_t size, const size_t nmemb, std::string *s) noexcept
{
const size_t newLength = size * nmemb;
const size_t oldLength = s->size();
s->resize(oldLength + newLength);
@sguzman
sguzman / useragentswitcher.xml
Created April 21, 2018 03:14
Massive list of user agents for User Agent Switcher by Chris Pederik http://forums.chrispederick.com/categories/user-agent-switcher
<useragentswitcher>
<folder description="Browsers - Windows">
<folder description="Legacy Browsers">
<useragent description="Arora 0.6.0 - (Vista)" useragent="Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/527 (KHTML, like Gecko, Safari/419.3) Arora/0.6 (Change: )" appcodename="" appname="" appversion="" platform="" vendor="" vendorsub=""/>
<useragent description="Avant Browser 1.2" useragent="Avant Browser/1.2.789rel1 (http://www.avantbrowser.com)" appcodename="" appname="" appversion="" platform="" vendor="" vendorsub=""/>
<useragent description="Chrome 4.0.249.0 (Win 7)" useragent="Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.0 Safari/532.5" appcodename="" appname="" appversion="" platform="" vendor="" vendorsub=""/>
<useragent description="Chrome 5.0.310.0 (Server 2003)" useragent="Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US) AppleWebKit/532.9 (KHTML, like Gecko) Chrome/5.0.310.0 Safari/532.9" appcodename="" appname=""
@sguzman
sguzman / build.sc
Created April 1, 2018 10:27
Build file for mill that works with binding.scala
import mill._
import mill.scalalib._
import mill.scalajslib._
import coursier.maven.MavenRepository
import publish._
object scalajs extends ScalaJSModule {
/** Main */
def mainClass = Some("com.github.sguzman.scala.js.Main")
@sguzman
sguzman / build.sc
Created March 31, 2018 23:44
Really happy with this build.sc file for mill build tool
import mill._
import mill.scalalib._
import coursier.maven.MavenRepository
import publish._
import java.io.File
object brotli extends PublishModule {
/** Publish version */
def publishVersion = "1.0.0"