Skip to content

Instantly share code, notes, and snippets.

View vadviktor's full-sized avatar
🍀
Mining Ruby 💎 ⛏️

Viktor (Icon) VAD 🍀 vadviktor

🍀
Mining Ruby 💎 ⛏️
View GitHub Profile
@vadviktor
vadviktor / Manjaro_HyperV_Setup.md
Created September 13, 2022 08:04 — forked from Zackptg5/Manjaro_HyperV_Setup.md
Manjaro HyperV Install Guide

Deprecated - Microsoft quit updating vm tools in favor of WSL2, it's only a matter of time before this breaks untirely (if it isn't already).

Credits, the original guide which has strangely vanished but can still be found via wayback machine here

This is largely the same as the original but with some updates

  • Setup a new machine in HyperV Manager. Make sure you choose 'Generation 2' and assign default switch for networking (or whatever other adapter you use). Then go to the new VM's settings, disable secure boot, and attach the manjaro iso to it (at the time of writing this, gnome doesn't work).
  • Boot up the vm, you'll be meeting with a black screen or the cli will show it stopped around display starting or whatever. Drop into terminal with CTL + ALT+ F2.
  • Login and type: pacman -Sy && pacman -S xf86-video-fbdev
  • Then restart the display manager: `systemctl r
@vadviktor
vadviktor / openinbrowser.go
Created June 9, 2022 07:46 — forked from nanmu42/openinbrowser.go
Golang: Open URL in Browser
func openBrowser(url string) {
var err error
switch runtime.GOOS {
case "linux":
err = exec.Command("xdg-open", url).Start()
case "windows":
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
case "darwin":
err = exec.Command("open", url).Start()
@vadviktor
vadviktor / gist:d888b13139c17dc0040add879264b313
Created April 25, 2018 06:32 — forked from thomas11/gist:2909362
Log memory usage every n seconds in Go #golang
import (
"runtime"
"time"
)
...
go func() {
for {
var m runtime.MemStats
@vadviktor
vadviktor / compress.go
Created November 8, 2017 13:30 — forked from iamralch/compress.go
ZIP archives in Golang
import (
"archive/zip"
"io"
"os"
"path/filepath"
"strings"
)
func zipit(source, target string) error {
zipfile, err := os.Create(target)
@vadviktor
vadviktor / PHP Array.php.js
Created July 25, 2017 17:12 — forked from mca-gif/PHP Array.php.js
PHP Array Data Extractor for the IntelliJ IDEA Platform
function eachWithIdx(iterable, f) { var i = iterable.iterator(); var idx = 0; while (i.hasNext()) f(i.next(), idx++); }
function mapEach(iterable, f) { var vs = []; eachWithIdx(iterable, function (i) { vs.push(f(i));}); return vs; }
function escape(str) {
str = com.intellij.openapi.util.text.StringUtil.escapeXml(str);
return str;
}
function quote(str) {
return '"' + str + '"';
@vadviktor
vadviktor / JSON.js
Created July 25, 2017 17:12 — forked from mca-gif/JSON.js
JSON Data Extractor for the IntelliJ IDEA Platform
function eachWithIdx(iterable, f) { var i = iterable.iterator(); var idx = 0; while (i.hasNext()) f(i.next(), idx++); }
function mapEach(iterable, f) { var vs = []; eachWithIdx(iterable, function (i) { vs.push(f(i));}); return vs; }
OUT.append(JSON.stringify( mapEach(ROWS, function(row, row_idx) {
var r = {};
eachWithIdx(COLUMNS, function(col, col_idx) { r[ col.name() ] = row.value(col); });
return r;
})));
@vadviktor
vadviktor / Markdown-JavaScript.markdown.js
Created July 25, 2017 17:12 — forked from jimschubert/Markdown-JavaScript.markdown.js
DataGrip (IntelliJ) output SQL results to Markdown
if (!String.prototype.repeat) {
// polyfill from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat
String.prototype.repeat = function(count) {
'use strict';
if (this == null) {
throw new TypeError('can\'t convert ' + this + ' to object');
}
var str = '' + this;
count = +count;
if (count != count) {
@vadviktor
vadviktor / Grub_Powerup.md
Created June 28, 2017 10:50 — forked from MaxLaumeister/Grub_Powerup.md
Grub Init Tune: Mario Bros. Mushroom Powerup

Grub Init Tune - Mario Bros. Mushroom Powerup

This Grub Init Tune will make your computer sound like a Super Mushroom every time you turn it on! This only works for the Grub bootloader - this generally means you need to have Linux (or other Grub-based OS) installed.

Here's the code, which goes in your /etc/default/grub file:

GRUB_INIT_TUNE="1750 523 1 392 1 523 1 659 1 784 1 1047 1 784 1 415 1 523 1 622 1 831 1 622 1 831 1 1046 1 1244 1 1661 1 1244 1 466 1 587 1 698 1 932 1 1195 1 1397 1 1865 1 1397 1"

Installation Instructions

@vadviktor
vadviktor / puma_rails_heroku.rb
Created February 26, 2017 00:05 — forked from subelsky/puma_rails_heroku.rb
Setting up Puma and Rails on Heroku
# Gemfile
gem "puma"
# Procfile
web: bundle exec puma -p $PORT -e $RACK_ENV -C config/puma.rb
# add to config block config/environments/production.rb
config.threadsafe!
# get rid of NewRelic after_fork code, if you were doing this:
@vadviktor
vadviktor / fork_with_new_connection.rb
Last active August 29, 2015 14:25 — forked from danieldbower/fork_with_new_connection.rb
Forking Processes In Ruby On Rails
# Logic for forking connections
# The forked process does not have access to static vars as far as I can discern, so I've done some stuff to check if the op threw an exception.
def fork_with_new_connection
# Store the ActiveRecord connection information
config = ActiveRecord::Base.remove_connection
pid = fork do
# tracking if the op failed for the Process exit
success = true