Skip to content

Instantly share code, notes, and snippets.

View SeriousM's full-sized avatar
🌟
Focusing

Bernhard Millauer SeriousM

🌟
Focusing
View GitHub Profile
@SeriousM
SeriousM / gist:ed5a0dc0ed5d9a8e09b9
Created April 14, 2015 12:51
VS2013+ magic/pseudo variables
in the watch window or quickwatch:
"$exception": the current exception that is currently available. it has a much better debug experience in the quickwatch because it can look into the exception's type
"{num}#": eg "1#". this is a reference to an object with ObjectId. it acts as a weak-reference and does not affect the GC'ability of the object. http://blogs.msdn.com/b/zainnab/archive/2010/03/04/make-objectid-vstipdebug0015.aspx
"$ReturnValue": contains the return value from the last exited method. The autos-window contains a much better display of that. http://blogs.msdn.com/b/visualstudioalm/archive/2013/06/27/seeing-function-return-values-in-the-debugger-in-visual-studio-2013.aspx
"$user": displays the information about the current user - eg to check for permissions, impersonations, etc
"{number-variable},h": displays the variable as hex
"{number-variable},d": displays the variable as decimal/number
To catch errors during script execution:
WHENEVER SQLERROR EXIT FAILURE
@SeriousM
SeriousM / youtube_daily_tracks.cs
Created December 17, 2012 13:45
Get YouTube Daily Top Tracks Playlists
List<Task> tasks = new List<Task>();
for (int i = 1; i <= 1000; i++) {
var reqT = new HttpClient().GetAsync("http://www.youtube.com/playlist?list=MCUS.." + i);
reqT.ContinueWith(t => {
var req = t.Result;
if (req.IsSuccessStatusCode) {
var title = Regex.Match(req.Content.ReadAsStringAsync().Result, "(<title>).*(</title>)").ToString().Replace("<title>", string.Empty).Replace("</title>", string.Empty);
@SeriousM
SeriousM / NOTES.md
Last active December 16, 2015 00:08
This script is able to push the source from one repository/branch to another repository/branch.

Windows

On windows you can specify file repositories with file:///\\<computer>\<path> (ex: file:///\\homepc\repos\git-backup.git).

It is always a good practice to postfix the folder with .git to indicate that this folder is a bare repository.

#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
//==============================================================================
// Casper generated Mon Jun 10 2013 09:27:47 GMT+0200 (W. Europe Daylight Time)
//==============================================================================
var x = require('casper').selectXPath;
var casper = require('casper').create();
casper.options.viewportSize = {width: 1920, height: 1137};
casper.start('http://wetter.orf.at/oes/');
casper.waitForSelector("undefined",
function success() {
@SeriousM
SeriousM / readme.md
Created July 7, 2013 19:18
Gem development

loading gem git clone <git repo>

install local gem (this will load the local one instead the official one) gem install <gem name>

release new version rake release

using System;
using System.Runtime.InteropServices;
// ReSharper disable SuspiciousTypeConversion.Global
// ReSharper disable InconsistentNaming
namespace VideoPlayerController
{
/// <summary>
/// Controls audio using the Windows CoreAudio API
/// from: http://stackoverflow.com/questions/14306048/controling-volume-mixer
@SeriousM
SeriousM / introrx.md
Created January 26, 2016 17:49 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
// Author: Darren Schnare, modified by Bernhard Millauer
// Keywords: javascript,interpolation,string,ruby
// License: MIT ( http://www.opensource.org/licenses/mit-license.php )
// Repo: https://gist.github.com/SeriousM/908ee1e67c79681e8c52
String.prototype.interpolate = function (o) {
if (!o) return this;
function getValue(str, context) {
var ix = str.lastIndexOf('()');
if (ix > 0 && ix + '()'.length == str.length){
return context[str.substring(0, ix)]();