Skip to content

Instantly share code, notes, and snippets.

View piksel's full-sized avatar
📠

nils måsén piksel

📠
View GitHub Profile
@piksel
piksel / piksel.jswarrior.js
Last active December 25, 2015 02:59
JSWarrior full completion code
var healAmount = 2;
var dangerThreshold = 10;
var safeDistance = 4;
var tryHeal = function(warrior, currHealth){
warrior.isFleeing = warrior.isFleeing || false;
if(typeof warrior.lastHealth !== 'undefined' &&
currHealth < warrior.lastHealth){
if(warrior.stepsFromWall >= safeDistance &&
currHealth < dangerThreshold)
@piksel
piksel / gist:7360935
Created November 7, 2013 20:01
Totally unnecessary code.
for (int i = 0; i < 16; i ++)
{
byte bt = bytes[i];
for (int b = 0; b < 8; b++)
{
int bit = (bt >> b) & 1;
bits[(i * 8) + b] = (bool) bit;
}
}
@piksel
piksel / hitbox-dark
Last active August 29, 2015 14:05
darker theme for hitbox chat
jQuery:
$('head').append('<style>.chatBody li>div { color: #eee }.chat, .chat-table tr, .chat-table td { background: #333; }.name {text-shadow:0 0 3px #000} a {color: #A4DB00; }</style>')
css:
.chatBody li>div { color: #eee }.chat, .chat-table tr, .chat-table td { background: #333; }.name {text-shadow:0 0 3px #000} a {color: #A4DB00; }
@piksel
piksel / shellshock.sh
Created September 26, 2014 15:25
Shellshock test
echo -ne "\nShellshock: "; env x='() { :;}; echo -n not\ ' bash 2> /dev/null -c "echo patched"; bash --version | head -n1
private void CloseConnections(Action action)
{
panel2.Dock = DockStyle.Fill;
panel2.Visible = true;
new Thread(() =>
{
Log("Closing connections...");
foreach (TcpListener tl in tcpListeners)
{
Log("- Closing listening socket " + tl.LocalEndpoint.ToString());
@piksel
piksel / web.config.xml
Last active September 1, 2015 06:54
web.config for ember.js routing
<configuration>
<system.web>
<rewrite>
<rules>
<rule name="Ember.js routing" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
@piksel
piksel / manifest.yaml
Last active December 11, 2015 16:37
Example manifest YAML for Hale Check
information:
name: My Check
version: 1.0
website: http://dev.nesc.io/my-check
author:
name: Nomen Nescio
company: NN inc.
email: nomen@nesc.io
website: http://nesc.io
public static class ServiceProvider
{
static Dictionary<Type, object> instances = new Dictionary<Type, object>();
public static Nullable<T> GetService<T>() where T : struct
{
var t = typeof(T);
if(instances.ContainsKey(t)) {
return new Nullable<T>((T)instances[t]);
}
PM> Install-Package -Version 1.13.2 NetTopologySuite
Package 'NetTopologySuite.1.13.2' already exists in project 'Webvind3.WinForms'
PM> Install-Package HockeySDK.Core
Attempting to gather dependencies information for package 'HockeySDK.Core.2.2.2' with respect to project 'Webvind3.WinForms', targeting '.NETFramework,Version=v4.5'
Attempting to resolve dependencies for package 'HockeySDK.Core.2.2.2' with DependencyBehavior 'Lowest'
Install-Package : Unable to find a version of 'GeoAPI' that is compatible with 'NetTopologySuite 1.14.0 constraint: GeoAPI (≥ 1.7.4 && < 1.8.0)', 'ProjNET4GeoAPI 1.3.0.3 constraint: GeoAPI (≥ 1.7.1)', 'SharpMap 1.1.0
constraint: GeoAPI (= 1.7.2)'.
At line:1 char:1
+ Install-Package HockeySDK.Core
@piksel
piksel / utils.cs
Created November 8, 2016 07:24
C# Utility functions and extensions
public static class DateTimeExtensions
{
private static readonly DateTime _unixEpoch = new DateTime(1970, 1, 1);
public static long ToUnixTime(this DateTime dt)
{
var span = dt - _unixEpoch;
return (long) (Math.Floor(span.TotalSeconds));
}
}