Skip to content

Instantly share code, notes, and snippets.

@stoivo
stoivo / Git superhelper
Created September 29, 2014 11:47
This is a tool to speed up git commands in terminal
function g {
# if you not in a repo STOP now
case $1 in
'' )
git status
;;
'loop' )
git_status_res_without_delete=$(git status | grep -v 'On branch' | grep -v 'Your branch is' | grep -v 'use "git push" to publish' | grep -v 'Changes to be committed' | grep -v 'use "git reset HEAD' | grep -v 'Changes not staged for' | grep -v 'to update what will be committed' | grep -v 'discard changes in working directory' | grep -v 'include in what will be committed' | grep -v "grep -v 'include in what will be committed'"| grep -v "git branch --unset-upstream" | grep -v "added to commit but untracked files present" | grep -v "nothing to commit, working dir" | grep -v " deleted: " | grep -v "Your branch and" | grep -v "different commits each, respectively." | grep -v "to merge the remote branch into yours)" | grep -v "You have unmerged paths" | grep -v "(fix conflicts and run " | grep -v "Unmerged paths:" | grep -v "to mark resolution)" | grep -v "renamed: ")
function setCurrentTabName () {
WID=$(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"| awk '{print $5}')
xdotool windowfocus $WID
xdotool key ctrl+i
xdotool key BackSpace
xdotool type $1
xdotool key Return
}
function maybeCreateNewTab() {
@stoivo
stoivo / regneklynge.java
Created February 2, 2017 14:12
regneklynge.java
public class Regneklynge {
int antNode;
ArrayList<Rack> racks = new ArrayList<Rack>();
public void setInnNode(Node node){
boolean sattInn = false
for (int i = 0; i < racks.length-1; i++) {
if (racks[i].setinNode(node)) {
sattInn = true;
break;
@stoivo
stoivo / add_csrf_token_to_request.js
Created May 19, 2017 10:26
This is one way to add csrf-token to your request from elm to rails. This is general solution, I use it with rails.
(function(){
var send = XMLHttpRequest.prototype.send,
token = document.querySelector("meta[name=csrf-token]").getAttribute("content");
XMLHttpRequest.prototype.send = function(data){
this.setRequestHeader('X-CSRF-Token', token);
return send.apply(this, arguments);
}
})();
ruby-2.4.2
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]
Environment
Ruby ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin17]
Rubygems 2.6.13
Bundler 1.16.0
Command /Users/user_name/.rbenv/versions/2.4.2/gemsets/product/bin/cap fb2016 doctor
# oneline
a=[self].unshift 'secret';a.unshift 33;a.unshift :unlock;s=%w[se nd].join'';m=self.prison.method s.to_sym;m.to_proc[*a]
# mulltiline
a=[self].unshift 'secret';
a.unshift 33;
a.unshift :unlock;
s=%w[se nd].join'';
m=self.prison.method s.to_sym;
m.to_proc[*a]
# /app/components/link_as_button.rb
class LinkAsButton
attr_reader :href
attr_reader :disabled
def initialize(
href:,
disabled: false
)
@href = href
@stoivo
stoivo / README
Last active October 25, 2021 20:54
Syncoid icinga setup check_syncoid
This is a script build to be run by nagios/icinga plugin system. It takes check who log ago is that thas synoic snapshot. We build this to be run on our server being backed up, as we are buying backup solution and we want to check that it was been copied out. If we has access to the server backing up our server we could have used sanoid --monitor-snapshots to verify that is has uptodate snapshots.
example
./check_syncoid asdasd -w 60 -c 90 -h spike -z lxd -r
-r traverse over a dataset recursively
-z <s> sets s ZFS dataset to check
-w <n> sets n to minutes before it is warning
-c <n> sets n to minutes before it is critical
-h <s> sets s as the hostname in the syncoid snapshot name