Skip to content

Instantly share code, notes, and snippets.

View zored's full-sized avatar
🏠
Working from home

Robert Akhmerov zored

🏠
Working from home
View GitHub Profile
@zored
zored / convert.php
Last active March 28, 2017 15:34
Convert comments to one-line when possible.
#!/usr/bin/env php
<?php
$path = $argv[1];
if (empty($path)) {
echo "Path is not set.";
exit(1);
}
file_put_contents(
@zored
zored / tunnelbear-toggle.sh
Last active August 30, 2022 12:15
Toggle TunnelBear from macOS console. Enable or disable TunnelBear VPN with CLI. Compatable with TunnelBear 3.8.0. Based on SH and AppleScript.
#/usr/bin/env bash
# Include this file in `~/.bash_profile` with `source /path/to/tunnelbear-toggle.sh`.
# Toggle TunnelBear activity.
#
# Example usage:
# `tunnelbear-toggle`
# `tunnelbear-toggle 1`
tunnelbear-toggle ()
{
@zored
zored / TestArea.java
Last active May 8, 2019 18:04
The Last Script for My Phone
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
@zored
zored / ram_benchmark.sh
Last active January 9, 2020 10:29
Linux RAM speed benchmark
#!/bin/sh
set -ex
ram_dir=~/RAM_test
# Create directory and mount RAM-based filesystem:
mkdir $ram_dir
sudo mount tmpfs -t tmpfs $ram_dir
(
cd $ram_dir
dd if=/dev/zero of=data_tmp bs=1M count=512 # - write.
@zored
zored / main.go
Last active November 3, 2022 02:30
Golang shebang for scripting
//usr/bin/env go run "$0" "$@"; exit "$?"
package main
import "fmt"
func main() {
fmt.Println("ok")
}
@zored
zored / read_one_symbol.ts
Created June 1, 2020 12:59
Deno read one symbol
#!/usr/bin/env -S deno run --unstable
while (true) {
const buffer = new Uint8Array(1);
Deno.setRaw(0, true);
await Deno.stdin.read(buffer);
Deno.setRaw(0, false);
console.log(buffer);
}
@zored
zored / sample.ts
Last active September 1, 2020 12:07
Deno 16k output limit
await Deno.stdout.write(new TextEncoder().encode('v'.repeat(20000)))
@zored
zored / README.md
Last active September 12, 2021 16:42
Video rename (with Deno) and convertion from h.265 to h.264 (with ffmpeg)

How I move files from iPhone to Google Drive

  • Copy files to computer using 3uTools.
  • Rename files with for c in save-renames rename; do deno run -A --unstable rename.ts $c; done.
  • Remove .webp files because they are trash.
  • Move video files in ./video directory (.mp4, .mov).
  • Create ./video_x264 and run ./convert.sh.
  • Wait for million years.
  • Check ./video_x264 and remove ./video.
  • Review media collection with Filter UI.
@zored
zored / main.go
Created March 24, 2021 16:56
Random reader macOS error example
package main
import (
"crypto/rand"
"fmt"
)
func main() {
for i := 1; i <= 10000; i++ {
n, err := rand.Reader.Read(make([]byte, 10))
@zored
zored / main.go
Created July 19, 2021 21:25
Output compex structs as JSON for diff (for example in Jetbrains Goland)
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"math/rand"
"path/filepath"
)