Skip to content

Instantly share code, notes, and snippets.

Avatar

sarnobat

View GitHub Profile
@rosswd
rosswd / cs.md
Last active May 12, 2018
The stack, heap, registers and instructions
View cs.md

Stack, Heap, Registers and Instructions

  1. Stack (push, pop, stack pointer, stack frame pointer)
  2. Heap (malloc, calloc, global, static)
  3. Registers (addresses, values)
  4. Instructions (mov, add, jmp, jne)

The Stack (LIFO)

  • push adds an element to the top of the stack
  • pop removes the top element from the stack
@fsteffenhagen
fsteffenhagen / sum_fileseize.sh
Created Mar 3, 2017
sum human readable file sizes with numfmt and awk
View sum_fileseize.sh
# Input: list of rows with format: "<filesize> filename", e.g.
# filesizes.txt
#######################
# 1000K file1.txt
# 200M file2.txt
# 2G file3.txt
#
# Output:
cat filesizes.txt | numfmt --from=iec | awk 'BEGIN {sum=0} {sum=sum+$1} END {printf "%.0f\n", sum}'
View feedly-colorful-list-view.user.js
// ==UserScript==
// @name Feedly Colorful Listview
// @namespace http://feedly.colorful.list.view
// @description Colorizes items headers based on their source
// @include http*://feedly.com/*
// @include http*://*.feedly.com/*
// @version 0.11.2
// ==/UserScript==
const colors = {};
View jooq-mockito-deep-stub-example
DSLContext database = Mockito.mock(DSLContext.class, Mockito.RETURNS_DEEP_STUBS);
Mockito.when(database.select(ACTIVITY_TYPE.ID)
.from(ACTIVITY_TYPE)
.where(ACTIVITY_TYPE.SINGLE_PERSON_USABLE.isTrue())
.fetch(ACTIVITY_TYPE.ID))
.thenReturn(ImmutableList.of(singleActivityTypeId));
Mockito.when(database.select(ACTIVITY_TYPE.ID)
.from(ACTIVITY_TYPE)
@inooid
inooid / .bash_profile
Created Mar 16, 2015
Google command to search on Google from the command line (Mac OS X)
View .bash_profile
# Command to open the webbrowser and immediately start searching
# for the right keyword.
#
# Usage:
# $ google test query
# $ => Opens the browser on http://www.google.com/search?q=test+query
#
google()
{
@rmorenobello
rmorenobello / setSystemPropertyFromCLI.groovy
Last active Nov 2, 2020
How to set and retrieve JVM system variables when running java/groovy from CLI
View setSystemPropertyFromCLI.groovy
// http://stackoverflow.com/questions/8098564/is-it-possible-to-specify-java-system-properties-when-running-groovy-from-comman
/*
System properties are set on the java command line using the
java -Dpropertyname=value
syntax.
They can also be added at runtime using
System.setProperty(name, value)
or via the various
System.getProperties().load()
methods.
@pascalalich
pascalalich / eclipse-templates.xml
Created Feb 18, 2015
Eclipse Templates for Java logging, hashCode, equals, and toString with SLF4J and Guava
View eclipse-templates.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?><templates><template autoinsert="true" context="java" deleted="false" description="equals (Guava)" enabled="true" name="equals">${:import(com.google.common.base.Objects)}&#13;
@Override&#13;
public boolean equals(final Object obj) {&#13;
if (this == obj) {&#13;
return true;&#13;
}&#13;
if (obj == null) {&#13;
return false;&#13;
}&#13;
if (getClass() != obj.getClass()) {&#13;
@andrewh
andrewh / anyconnect.scpt
Last active Mar 22, 2021
Applescript to automate the Cisco AnyConnect SSL VPN client on OS X Mavericks
View anyconnect.scpt
-- 1. Place in ~/Library/Scripts and enable the Applescript menu via the Applescript Editor
-- 2. Substitute "vpn.example.com" and "redacted" for your VPN server and password
-- 3. Open Security & Privacy System Preferences, go to Privacy, Accessibility
-- 4. Enable Applescript Editor and System UI Server
-- 5. Trigger script from the menu
-- 6. Enjoy being connected
tell application "Cisco AnyConnect Secure Mobility Client"
activate
end tell
@p1nox
p1nox / using_meld_on_mac.md
Last active Mar 17, 2021
Using meld on Mac
View using_meld_on_mac.md

Using Meld merging tool on Mac

brew tap homebrew/cask
brew cask install meld
  • If meld doesn't start while executing from terminal, try this:

Modify the /usr/local/Caskroom/meld/3.19.2-r6,osx-15/meld.wrapper.sh script installed by brew to the following

View hide others.applescript
tell application "System Events"
--set visible of every process whose visible is true and name is not in {"Finder", name of current application} to false
set visible of every process whose visible is true and name is not "Finder" and frontmost is false to false
end tell