Skip to content

Instantly share code, notes, and snippets.

View LucasMW's full-sized avatar

Lucas Menezes LucasMW

View GitHub Profile
@mattiasgustavsson
mattiasgustavsson / main.c
Created March 5, 2024 19:18
Minimal code example for creating a window to plot pixels to
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <windows.h>
#pragma comment( lib, "user32.lib" )
#pragma comment( lib, "gdi32.lib" )
#define SCRW 640
#define SCRH 480
@joshbetz
joshbetz / Webview.swift
Last active October 13, 2023 19:36
SwiftUI Webview with a Progress Bar
struct Webview: UIViewControllerRepresentable {
let url: URL
func makeUIViewController(context: Context) -> WebviewController {
let webviewController = WebviewController()
let request = URLRequest(url: self.url, cachePolicy: .returnCacheDataElseLoad)
webviewController.webview.load(request)
return webviewController
@LucasMW
LucasMW / instruction.md
Last active October 9, 2018 13:23
Open files containing the word "x" and file name contains "y"

Requires ag (The Silver Searcher)

brew install ag

General formula:

ide $(ag x -G y -l)

Example:

Open with android studio all files from current direct containing the word "order" and file name contains Activity.java

studio $(ag order -G Activity.java -l)

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@laanwj
laanwj / blocktoimg.py
Last active January 31, 2024 11:06
tools to write (block) data to png files and vice versa
#!/usr/bin/env python3
# Distributed under the MIT software license
import binascii, struct, sys, io, argparse
from PIL import Image
IMG_WIDTH = 512 # could be made adaptive...
MIN_HEIGHT = 4 # minimum height of image; twitter won't let us upload anything smaller
BYTES_PER_PIXEL = 4 # RGBA, 8 bit
def div_roundup(x,y):
@barbietunnie
barbietunnie / udemy-courses-download-using-cookies.md
Last active May 10, 2024 18:17
Downloading Udemy videos with youtube-dl

How to download your Udemy course videos using youtube-dl

$ youtube-dl --list-extractors | grep udemy

Steps

  1. Get link to the course to download. e.g. https://www.udemy.com/course-name/
  2. Login into udemy website, save the cookie from chrome using Chrome (Cookie.txt)[1] export extension. Save it to file udemy-cookies.txt
  3. Get the link of the video that you want to download. usually in format. Use the command provided below where you have to replace the {course_link} and {path_to_cookies_file} with respective paths.
$ youtube-dl {course_link} --cookies {path_to_cookies_file}
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 5.
DATA DA EXTRACAO,HORA DA EXTRACAO,NUMERO DA INSCRICAO,NOME DO FILIADO,SIGLA DO PARTIDO,NOME DO PARTIDO,UF,CODIGO DO MUNICIPIO,NOME DO MUNICIPIO,ZONA ELEITORAL,SECAO ELEITORAL,DATA DA FILIACAO,SITUACAO DO REGISTRO,TIPO DO REGISTRO,DATA DO PROCESSAMENTO,DATA DA DESFILIACAO,DATA DO CANCELAMENTO,DATA DA REGULARIZACAO,MOTIVO DO CANCELAMENTO
"04/05/2016","00:43:20","017587631783","ALDO FERNANDES SOBREIRA","PSOL","PARTIDO SOCIALISMO E LIBERDADE","AL","28711","SÃO MIGUEL DOS CAMPOS","18","92","29/09/2005","CANCELADO","OFICIAL","19/04/2013","18/08/2008","18/08/2008","","A pedido do eleitor"
"04/05/2016","00:43:20","031234631716","JOSE ROBSON DA SILVA","PSOL","PARTIDO SOCIALISMO E LIBERDADE","AL","28711","SÃO MIGUEL DOS CAMPOS","18","78","10/01/2006","REGULAR","OFICIAL","19/04/2013","","","",""
"04/05/2016","00:43:20","029507791708","ELIVANIA MARIA DA SILVA","PSOL","PARTIDO SOCIALISMO E LIBERDADE","AL","27316","CANAPI","27","23","31/08/2007","REGULAR","OFICIAL","14/11/2009","","","",""
"04/05/2016","00:43:20","01950862
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
@aras-p
aras-p / preprocessor_fun.h
Last active May 23, 2024 08:26
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@cpq
cpq / embed.c
Last active May 15, 2024 17:20
How to embed data files into C/C++ executable
// Copyright (c) Sergey Lyubka, 2013.
// All rights reserved.
// Released under the MIT license.
// This program is used to embed arbitrary data into a C binary. It takes
// a list of files as an input, and produces a .c data file that contains
// contents of all these files as collection of char arrays.
// Usage:
// 1. Compile this file:
// cc -o embed embed.c