Skip to content

Instantly share code, notes, and snippets.

View xerxesb's full-sized avatar

Xerxes Battiwalla xerxesb

View GitHub Profile
@xerxesb
xerxesb / powertop-output-with-gui.csv
Last active February 26, 2021 05:27
Powertop Output from two different runs (one booted into desktop mode, the other in console)
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
____________________________________________________________________
P o w e r T O P
____________________________________________________________________
* * * System Information * * *
PowerTOP Version;v2.9 ran at Fri Feb 26 15:19:37 2021
Kernel Version;Linux version 5.4.0-65-generic
System Name;LENOVOLNVNB161216Legion Y7000 2019
@xerxesb
xerxesb / gist:5881133
Last active December 19, 2015 02:09
Movie of the month
The Prestige
The Crying Game
Anchorman
Nikita (tick) #movieofthemonth 7/10. Some bits were exciting but mostly it was too slow.
Training Day (tick) #movieofthemonth 8/10 great film.
@xerxesb
xerxesb / new_gist_file
Created April 7, 2013 23:43
Include javascript dynamically
/* Modified from http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml */
var url= "";
var fileref = document.createElement('script');
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", url);
document.getElementsByTagName("head")[0].appendChild(fileref);
@xerxesb
xerxesb / gist:4654224
Last active December 11, 2015 20:18
First run at a solution to the Call Recording/Ordering kata
using System;
using System.Collections.Generic;
using System.Diagnostics;
using NUnit.Framework;
using Shouldly;
using System.Linq;
namespace MethodInfos
{
public class Formatter
@xerxesb
xerxesb / gist:3548956
Created August 31, 2012 04:03
How many ways can the letters in australia be arranged so that ONLY 2 A's are together?
# This generates all combinations of words with the letters in 'australia',
# and then filters down to include only words with two consequtive "a"s
# and then excludes any words with 3 consecutive "a"s, leaving the words with only 2 a's together.
#
# Answer: 30240
class String
def each_char_with_index
0.upto(size - 1) do |index|
yield(self[index..index], index)
@xerxesb
xerxesb / llblgen-in-memory-predicate-filtering.cs
Created August 25, 2012 04:29
Look, ma! I found in-memory predicate filtering.
public IEntityCollection2 FilterEntities(IEntityCollection2 collection, IRelationPredicateBucket filterBucket)
{
collection.DefaultView.Filter = filterBucket.PredicateExpression; // only works for basic filter expressions
return collection.DefaultView.ToEntityCollection();
/*
// say goodbye to all this shitty code.
var result = CreateEntityCollection(EntityType(collection));
var filterField = "";
object filterValue = null;
My app links in a 3rd party library (QCAR)
In the top of my .cpp file I have:
#include <QCAR/TrackerManager.h>
In one of the methods of my class, i'm making the following call (which fails to link)
QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance();
it fails with the following error:
@xerxesb
xerxesb / gist:2798861
Created May 27, 2012 02:58
Xerxes solutions to Run-Length-Encoding problems
import Data.List (group)
data Segment x = Single x | Multiple Int x
deriving (Show, Eq)
encodeModified :: (Eq a) => [a] -> [Segment a]
--encodeModified xs = map (\charset ->
-- if ((length charset) == 1)
-- then (Single (head charset))
@xerxesb
xerxesb / gist:2788221
Created May 25, 2012 13:38
Xerxes solutions to typeclass problems
data List a = Elem a | List [List a] deriving (Show)
flatten' :: List a -> [a]
flatten' (Elem x) = [x]
flatten' (List (x:xs)) = flatten' x ++ flatten' (List xs)
flatten' (List []) = []
data Tree a = Empty | Node a (Tree a) (Tree a)
deriving (Eq, Show, Read)
@xerxesb
xerxesb / gist:1744913
Created February 5, 2012 11:39
Netbank hackery
var BetterNetbank = {
inject: function(table) {
if ($("#" + table).length > 0) {
$('#' + table + ' thead tr').prepend('<th>X</th>');
$('#' + table + 'Body > tr').map(function() {
$(this).prepend('<td><input type="checkbox" /></td>');
});
}
}
}