Skip to content

Instantly share code, notes, and snippets.

View mvastola's full-sized avatar

Mike Vastola mvastola

View GitHub Profile
@Diagg
Diagg / RunScriptBlockAsTrustedInstaller.ps1
Last active July 11, 2024 23:17
Run Powershell Script block as Trusted installer using Scheduled Task under Admin account
# Run Powershell scriptblock as Trusted Installer From Admin context (Yeah, MDT) using Scheduled Task.
# Credit due to : https://www.tiraniddo.dev/2019/09/the-art-of-becoming-trustedinstaller.html
$ScriptBlock = {
$Script:TsEnv = New-Object PSObject
$Script:TsEnv|Add-Member -MemberType NoteProperty -Name 'SystemHostName' -Value ([System.Environment]::MachineName)
$Script:TsEnv|Add-Member -MemberType NoteProperty -Name 'SystemIPAddress' -Value (Get-NetIPAddress -AddressFamily IPv4 -PrefixOrigin Dhcp -AddressState Preferred).IPAddress
$Script:TsEnv|Add-Member -MemberType NoteProperty -Name 'SystemOSversion' -Value ([System.Environment]::OSVersion.VersionString)
@warsocket
warsocket / disable-connectivity-check.sh
Created December 8, 2020 10:30
Fix spotify code 4 error on ubuntu / linux mint by disabling the connectivity-check amed toward a canonical server
busctl --system set-property org.freedesktop.NetworkManager /org/freedesktop/NetworkManager org.freedesktop.NetworkManager ConnectivityCheckEnabled "b" 0
@schweigert
schweigert / Embedding GoLang into a Ruby application.md
Last active October 31, 2024 21:59
Embedding GoLang into a Ruby application - Blogpost to Magrathealabs

Go Title

I am passionate about Ruby, but its execution time compared to other languages is extremely high, especially when we want to use more complex algorithms. In general, data structures in interpreted languages become incredibly slow compared to compiled languages. Some algorithms such as ´n-body´ and ´fannkuch-redux´ can be up to 30 times slower in Ruby than Go. This is one of the reasons I was interested in embedding Go code in a Ruby environment.

For those who do not know how shared libraries operate, they work in a similar way as DLLs in Windows. However, they have a native code with a direct interface to the C compiler.

Note Windows uses the DLL system, and in this case, this does not necessarily have to be in native code.

One example is DLLs written in C#, which runs on a virtual machine. Because I do not use windows, I ended up not testing if it is poss

@toch
toch / docset_for_gem.sh
Created April 26, 2016 15:42
a Bash script to generate docset for Zeal from a group of gems
#!/bin/bash
# rubygem is required
# yard is required: gem install yard
# doc_to_dash is required: gem install doc_to_dash
GEM_NAME_PREFIX=$1
DOCSET_DIR=$2
TMP_DIR=$(mktemp -d)
@maximilian-lindsey
maximilian-lindsey / express_in_electron.md
Last active November 3, 2024 21:30
How to run Express inside an Electron app

How to run Express inside an Electron app

You can run your Express app very easily inside your Electron app.

All you need to do is to:

  • place all the files of your Express app inside a new app folder in your_electron_app\resources\app
  • reconfigure the app.js file
  • refactor some relative pathes in your Express app
@robinmonjo
robinmonjo / main.go
Created July 27, 2014 15:03
Go pty setup for interactive shell
package main
import (
"code.google.com/p/go.crypto/ssh/terminal"
"github.com/kr/pty"
"io"
"os"
"os/exec"
)
@tylergannon
tylergannon / gist:7690997
Created November 28, 2013 12:19
Use HTTParty gem for making HTTP requests over unix domain sockets.
###########################################################
# net/socket_http.rb
###########################################################
module Net
# Overrides the connect method to simply connect to a unix domain socket.
class SocketHttp < HTTP
attr_reader :socket_path
# URI should be a relative URI giving the path on the HTTP server.
@michaelminter
michaelminter / colors.rb
Created October 19, 2012 15:03
Ruby globals for working with terminal ANSI color codes
CLEAR = "\e[0m"
BOLD = "\e[1m"
# Colors
BLACK = "\e[30m"
RED = "\e[31m"
GREEN = "\e[32m"
YELLOW = "\e[33m"
BLUE = "\e[34m"
MAGENTA = "\e[35m"
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active November 3, 2024 07:39
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
# Rack middleware that drops non properly encoded cookies that would hurt the ActionDispatch::Cookies middleware.
#
# This is actually a hotfix for issues
# * https://github.com/rack/rack/issues/225
# * https://github.com/rails/rails/issues/2622
module CleanCookies
# Tests whether a string may be decoded as a form component
def decodable?(string)
URI.decode_www_form_component(string)
true