Skip to content

Instantly share code, notes, and snippets.

View typelogic's full-sized avatar
🏹

typelogic typelogic

🏹
View GitHub Profile
@typelogic
typelogic / ubuntu-run-dhclient-on-startup.md
Created February 11, 2019 09:24 — forked from mohamadaliakbari/ubuntu-run-dhclient-on-startup.md
Run dhclient on Startup in Ubuntu 18.04

dhclient is the Dynamic Host Configuration Protocol (DHCP) Client one would use to allow a client to connect to a DHCP server.

$ sudo nano /etc/rc.local

#!/bin/bash
dhclient
exit 0

$ sudo chmod 755 /etc/rc.local

@typelogic
typelogic / http_server.rs
Created May 20, 2019 10:48 — forked from mjohnsullivan/http_server.rs
Simple HTTP server example for Rust
// Updated example from http://rosettacode.org/wiki/Hello_world/Web_server#Rust
// to work with Rust 1.0 beta
use std::net::{TcpStream, TcpListener};
use std::io::{Read, Write};
use std::thread;
fn handle_read(mut stream: &TcpStream) {
let mut buf = [0u8 ;4096];
@typelogic
typelogic / curl.md
Created October 2, 2019 18:19 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@typelogic
typelogic / create-a-socket.c
Created November 3, 2019 14:23 — forked from ryran/create-a-socket.c
tiny C application to create a unix socket (UDS) file
#include <fcntl.h>
#include <sys/un.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
int main(int argc, char **argv)
{
// The following line expects the socket path to be first argument
@typelogic
typelogic / RealPathUtil.java
Created April 22, 2020 11:02 — forked from tatocaster/RealPathUtil.java
Real Path Utility class for Android, works for all API
public class RealPathUtil {
public static String getRealPath(Context context, Uri fileUri) {
String realPath;
// SDK < API11
if (Build.VERSION.SDK_INT < 11) {
realPath = RealPathUtil.getRealPathFromURI_BelowAPI11(context, fileUri);
}
// SDK >= 11 && SDK < 19
else if (Build.VERSION.SDK_INT < 19) {
@typelogic
typelogic / stockfish-interface.txt
Created May 9, 2020 05:41 — forked from aliostad/stockfish-interface.txt
stockfish - Description of the universal chess interface (UCI)
COPIED FROM https://build.opensuse.org/package/view_file/games/stockfish/stockfish-interface.txt?expand=1
Description of the universal chess interface (UCI) April 2006
=================================================================
* The specification is independent of the operating system. For Windows,
the engine is a normal exe file, either a console or "real" windows application.
* all communication is done via standard input and output with text commands,
@typelogic
typelogic / README.md
Created October 19, 2020 15:42 — forked from joyrexus/README.md
form-data vs -urlencoded

Nice answer on stackoverflow to the question of when to use one or the other content-types for POSTing data, viz. application/x-www-form-urlencoded and multipart/form-data.

“The moral of the story is, if you have binary (non-alphanumeric) data (or a significantly sized payload) to transmit, use multipart/form-data. Otherwise, use application/x-www-form-urlencoded.”


Matt Bridges' answer in full:

The MIME types you mention are the two Content-Type headers for HTTP POST requests that user-agents (browsers) must support. The purpose of both of those types of requests is to send a list of name/value pairs to the server. Depending on the type and amount of data being transmitted, one of the methods will be more efficient than the other. To understand why, you have to look at what each is doing

#!/bin/bash
# This script requires jq, a command line to to parse and format JSon.
# https://stedolan.github.io/jq/
function padBase64 {
STR=$1
MOD=$((${#STR}%4))
if [ $MOD -eq 1 ]; then
STR="${STR}="
@typelogic
typelogic / gradlesigning.md
Created November 9, 2020 07:58 — forked from phit/gradlesigning.md
Gradle Signing for Dummies

Setup

Windows

Download the GnuPG binary release for windows current version from the official site and install it.

Linux

Grab the latest gpg from your package manager if it's not installed already anyway ;)

Publish AAR to jCenter and Maven Central
=================
[![Twitter](https://img.shields.io/badge/Twitter-@LopezMikhael-blue.svg?style=flat)](http://twitter.com/lopezmikhael)
Now I'm going to list how to publish an Android libray to jCenter and then syncronize it with Maven Central:
1. I use "Android Studio" and I have this simple android lib that I would like to be available on maven: [CircularImageView](https://github.com/lopspower/CircularImageView)
2. In the library folder(module) I have the lib code abovementioned. And applying in the build.gradle of this folder `apply plugin: 'com.android.library'` I got as output an .aar in the build/outputs/aar/ directory of the module's directory