Skip to content

Instantly share code, notes, and snippets.

View lf94's full-sized avatar
🏔️
Hey how's it going

49fl lf94

🏔️
Hey how's it going
View GitHub Profile
@lf94
lf94 / hours.hs
Last active August 29, 2015 14:06
Calculate my working hours from a .hours file. Comparison of Python and Haskell.
-- Read in an hours file and print the total hours.
-- Hours file format:
-- Desc\tDate\tStartTime-EndTime
import System.Environment
import Data.List.Split
-- Return milliseconds
get_milliseconds :: [String] -> Double
get_milliseconds xs = hours + minutes
where
@lf94
lf94 / bjbj.hs
Created September 17, 2014 18:37
Big John's Beef Jerky Calculator
import System.Environment(getArgs)
import Graphics.Rendering.Chart
import Data.Colour
import Data.Colour.Names
import Data.Default.Class
import Graphics.Rendering.Chart.Backend.Diagrams
import Graphics.Rendering.Chart.Axis.Floating
import Control.Lens
lifetime_discount = 0.05
@lf94
lf94 / admin.js
Last active November 21, 2015 00:04
Fix Elegant Builder for WordPress 4.0
function et_pb_get_content( textarea_id ) {
var content;
content = $( '#' + textarea_id ).val(); //Why not just use jquery in the first place, since you know, it actually works?
return content.trim();
}
function et_pb_set_content( textarea_id, content ) {
$( '#' + textarea_id ).val( content );
}
@lf94
lf94 / plugin_header.c
Last active August 29, 2015 14:15
XFCE panel plugin heading
#include <libxfce4panel/xfce-panel-plugin.h>
static void constructor(XfcePanelPlugin *plugin);
XFCE_PANEL_PLUGIN_REGISTER_INTERNAL(constructor);
@lf94
lf94 / plugin_body.c
Last active August 29, 2015 14:15
XFCE panel plugin body
static void
constructor(XfcePanelPlugin *plugin) {
// Use any GTK_CONTAINER you wish, it will be packed into the XfcePanelPlugin (plugin) variable.
GtkWidget *scroll_win = gtk_scrolled_window_new(NULL, NULL);
/* Now program as if you were creating any old GTK application. */
// Pack your container into the plugin's container.
gtk_container_add(GTK_CONTAINER(plugin), scroll_win);
@lf94
lf94 / make.sh
Created February 17, 2015 23:30
XFCE panel plugin make.sh
#!/bin/sh
main=enceladus # Change this to your plugin's name
gcc -Wall -shared -o lib${main}.so -fPIC ${main}.c `pkg-config --cflags --libs libxfce4panel-1.0` `pkg-config --cflags --libs gtk+-3.0`
@lf94
lf94 / yourpluginname.desktop
Last active August 29, 2015 14:15
XFCE panel plugin desktop file
X-XFCE-Module=yourpluginname
X-XFCE-Module-Path=/usr/lib/xfce4/panel-plugins
@lf94
lf94 / excellent.hs
Created March 3, 2015 13:06
Original excellente.hs code to calculate Paypal earnings
{-# LANGUAGE OverloadedStrings #-}
import Data.Csv
import Data.Fixed
import Data.Vector as Vec (Vector, fromList, sum, length, toList)
import Data.ByteString.Lazy as B (readFile)
import Control.Monad
import Control.Applicative
import System.Environment
@lf94
lf94 / are_there_cats_reddit.js
Created April 2, 2015 10:34
A CasperJS test case to determine if Reddit has cats on its front page or not.
// Your test cases begin in here.
casper.test.begin("Reddit Top Links Tests", 1, function(test) {
// Your first test case starts here.
casper.start("http://reddit.com/", function() {
// In here, we have access to the website's (reddit's) DOM!
/*
So what we're doing is selecting all the entry links,
and then extracting their text, and then filtering
the link's text based on if they have the word "cat"
or not.
@lf94
lf94 / swift-compile.hs
Created May 5, 2015 09:31
runswiftlang.org command-line utility for compiling swift online
{-# LANGUAGE OverloadedStrings #-}
import Network.HTTP.Conduit
import qualified Data.ByteString.Lazy as L
import qualified Data.ByteString as BS
import System.IO
import Data.Aeson
data CompilerStatus = CompilerStatus
{