My personal notebook for day-to-day vim usage.
i / [Insert]
enters insert mode at current characterI
enters insert mode at beginning of linea
enters insert mode at next characterA
enters insert mode at end of line$
goto end of line
# Original __git_ps1 | |
$ time orig__git_ps1 || 0 | |
(my-branch) | |
real 0m1.102s | |
user 0m0.000s | |
sys 0m0.140s | |
# Lean function | |
$ time __git_ps1 || 0 | |
(my-branch) |
/// Some sorting algorithms written in Rust. | |
fn insertion_sort(vec: &mut Vec<i32>) { | |
let length: i32 = vec.len() as i32; | |
if length < 2 { | |
// Vector is already sorted if of length 0 or 1 | |
return; | |
} |
package tictactoegame.ui; | |
import javax.swing.*; | |
import java.awt.*; | |
public class SwingTicTacToe extends JFrame { | |
/** | |
* The font used for the buttons. | |
*/ |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <unistd.h> | |
#include <limits.h> | |
#include <sys/mount.h> | |
extern char * ffmount(char *path) | |
{ | |
int rc; |
def selection_sort(array): | |
for index in range(len(array)): | |
currentMin = array[index] | |
currentMinIndex = index | |
# check the minimum value in the sub-array after the current index | |
for subIndex in range(index + 1, len(array)): | |
if array[subIndex] < currentMin: | |
currentMin = array[subIndex] | |
currentMinIndex = subIndex | |
import numpy as np | |
import tensorflow as tf | |
batch_size = 1 | |
data_size = 10000 | |
batches = int(data_size / batch_size) | |
# X is a (n 2) matrix with random positive floats between 0 and 100 | |
X = np.random.rand(data_size, 2) | |
# Y is a (n 1) matrix with the sum of the two columns of X |
# This is a curl command to get live/real-time STM bus schedules for a stop. | |
# Note that the "Origin" request header set to "http://beta.stm.info" is necessary. | |
curl -H "Accept: application/json" -H "Origin: http://beta.stm.info" "https://api.stm.info/pub/i3/v1c/api/en/lines/{BUS_LINE}/stops/{STOP_ID}/arrivals?d={DATE_YYYY_MM_DD}&t={24H_TIME_HHMM}&direction={DIRECTION}&wheelchair=0&limit=5" | |
# {BUS_LINE} = Line number (e.g. 123) | |
# {STOP_ID} = Stop number (e.g. 12345) | |
# {DATE_YYYY_MM_DD} = The date, in the YYYYMMDD format (e.g. 20180208) | |
# {24H_TIME_HHMM} = The time, in 24-hour format (HHMM) (e.g. 1348) | |
# {DIRECTION} = Line direction, E/W/N/S |
// the shortest JS code to create and run an HTTP server, using the least amount of different characters possible. | |
// this only works on node.js for obvious reasons. | |
require('http').createServer((e,r)=>{r.write('r');r.end()}).listen(80) | |
// if you don't want any response body (just accept the connection): | |
require('http').createServer((e,r)=>r.end()).listen(80) |