Skip to content

Instantly share code, notes, and snippets.

View bratsche's full-sized avatar

Cody Russell bratsche

View GitHub Profile
void HandleSearchEntryActivated (object sender, EventArgs e)
{
var pattern = SearchPopupSearchPattern.ParsePattern (ToolbarView.SearchText);
if (pattern.Pattern == null && pattern.LineNumber > 0) {
DestroyPopup ();
var doc = IdeApp.Workbench.ActiveDocument;
if (doc != null && doc.Editor != null) {
doc.Select ();
doc.Editor.Caret.Location = new Mono.TextEditor.DocumentLocation (pattern.LineNumber, pattern.Column > 0 ? pattern.Column : 1);
doc.Editor.CenterToCaret ();
@bratsche
bratsche / gist:ee81699a6960fb3b1233
Last active August 29, 2015 14:23
Seq.findIndex
F# Interactive for F# 3.1 (Open Source Edition)
Freely distributed under the Apache 2.0 Open Source License
For help type #help;;
> let scale1 = seq { -0.5 .. 0.1 .. 0.5 } ;;
val scale1 : seq<float>
> scale1 |> Seq.toArray ;;
@bratsche
bratsche / unmuck.sh
Created October 12, 2015 19:14
Autoconf cleanup for El Capitan
#!/bin/sh
while true
do
if [ -d confdir-14B---/confdir-14B--- ]
then
mv confdir-14B---/confdir-14B--- a
fi
if [[ $? -ne 0 ]]
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
#include <string.h>
#include <sys/stat.h>
#include <stdio.h>
/* Don't get link errors because mkdir is redefined to rpl_mkdir. */
#undef mkdir
@bratsche
bratsche / cairo-win32-font-device-scale.diff
Created December 4, 2015 20:16
Cairo Win32 font changes for device scale
--- a/src/win32/cairo-win32-font.c
+++ b/src/win32/cairo-win32-font.c
@@ -379,6 +379,8 @@ _win32_scaled_font_create (LOGFONTW *logfont,
/* don't delete the hfont if we're using the one passed in to us */
f->delete_scaled_hfont = !f->scaled_hfont;
+ cairo_matrix_scale (font_matrix, 1.0 / device_scale, 1.0 / device_scale);
+ cairo_matrix_scale (ctm, device_scale, device_scale);
cairo_matrix_multiply (&scale, font_matrix, ctm);
status = _compute_transform (f, &scale);
@bratsche
bratsche / gist:ea3085141b35579f1fd5
Created January 18, 2016 20:13
Example custom mix task to seed the database using an existing seed file
# lib/mix/tasks/musikr.seed.ex
defmodule Mix.Tasks.Musikr.Seed do
use Mix.Task
@shortdoc "Seeds the database"
@moduledoc """
Seed the database using the file 'priv/repo/seeds.exs'
"""
public void SetSortFunc(int sort_column_id, Gtk.TreeIterCompareFunc sort_func) {
GtkSharp.TreeIterCompareFuncWrapper sort_func_wrapper = new GtkSharp.TreeIterCompareFuncWrapper (sort_func);
IntPtr user_data;
GLib.DestroyNotify destroy;
if (sort_func == null) {
user_data = IntPtr.Zero;
destroy = null;
} else {
user_data = (IntPtr) GCHandle.Alloc (sort_func_wrapper);
destroy = GLib.DestroyHelper.NotifyHandler;
@bratsche
bratsche / Main.elm
Last active March 22, 2016 01:31
Restricted access with elm-transit-router
module Main (..) where
import Effects exposing (Effects, Never, none)
import Json.Decode as Json
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import String
import StartApp
import Signal exposing (Address)
defmodule Foo.SessionController do
use Foo.Web, :controller
def create(conn, %{"session" => session_params}) do
case Foo.Session.authenticate(session_params) do
{:ok, user} ->
{:ok, jwt, _full_claims} = Guardian.encode_and_sign(user, :token)
conn
|> put_status(:created)
@bratsche
bratsche / git-ls-changes.sh
Last active December 15, 2016 16:11
Differentiate between modified and unmodified files
git ls-files | while read -r line; do
s=$(git status -s "$line");
if [ -n "$s" ]; then
echo "$s";
else
echo " $line";
fi;
done