Skip to content

Instantly share code, notes, and snippets.

View smiler's full-sized avatar

Christian Axelsson smiler

  • Uppsala, Sweden
View GitHub Profile
container.Register(Classes.FromAssemblyContaining(typeof(IRepository))
.BasedOn<IRepository>()
.If(Component.IsInSameNamespaceAs<BaseEntityRepository<BaseEntity>>())
.If(t => t.Name.EndsWith("Repository") && (t.Name.StartsWith("Foo") || t.Name.StartsWith("Bar")))
.Configure(c => c.DependsOn(ServiceOverride.ForKey("Session").Eq("db.session.second"))
.DependsOn(ServiceOverride.ForKey("SessionFactory").Eq("db.sessionfactory.second"))).LifestylePerThread());
@smiler
smiler / gist:1940454
Created February 29, 2012 12:22
SML web chat
(**************************************************************************
* File : inl2.sml
* Project : Inlämningsuppgift 2
* Author : Christian Axelsson
* Created : 2005-12-27
* Description : Webchat
**************************************************************************)
(*
load "TextIO"; load "Random"; load "Time"; load "Mosmlcgi"; load "Mosmlcookie";
*)
function easterDay($y) {
// Se http://aa.usno.navy.mil/faq/docs/easter.html
$c = floor($y / 100);
$n = $y - 19 * floor( $y / 19 );
$k = floor(( $c - 17 ) / 25);
$i = $c - floor($c / 4) - floor(( $c - $k ) / 3) + 19 * $n + 15;
$i = $i - 30 * floor( $i / 30 );
$i = $i - floor( $i / 28 ) * ( 1 - floor( $i / 28 ) * floor( 29 / ( $i + 1 ) )
* floor( ( 21 - $n ) / 11 ) );
$j = $y + floor($y / 4) + $i + 2 - $c + floor($c / 4);
@smiler
smiler / gist:1978320
Created March 5, 2012 13:33
jQuery tooltip plugin
/* CSS
.tooltip-bubble {
background-color: #fffff7;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border: 1px solid #7f7f7f;
padding: 8px;
margin-top: -4px;
}
.tooltip-bubble .tooltip-arrow {
namespace CampaignTracker.Data.Data {
public class CampaignTrackerDataReader : CampaignTrackerDataContext {
public CampaignTrackerDataReader() {
ObjectTrackingEnabled = false;
}
public CampaignTrackerDataReader( IDbConnection connection ) : base( connection ) {}
public CampaignTrackerDataReader( bool log ) {
root@eof:/root# cat do_nat.sh
#!/bin/sh
EXTIF="eth1"
#route add -net 192.168.1.0/24 dev eth1
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -F; iptables -t nat -F; iptables -t mangle -F
iptables -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE
#include <string>
#include <iostream>
int main(int argc, char* argv[])
{
std::string fileName("filename.obj");
if(fileName.substr(fileName.rfind(".") + 1) == "obj")
std::cout << "Yup";
else
std::cout << "Nope";
/// <summary>
/// Escapes an LDAP filter value.
/// </summary>
/// <param name="filter">Unescaped filter value.</param>
/// <param name="allowWildcard">If true, * will not be escaped.</param>
/// <returns><paramref name="filter"/> with all occurances of (, ), \, NUL and / (and eventually *) replaced.</returns>
/// <remarks>See http://msdn.microsoft.com/en-us/library/windows/desktop/aa746475(v=vs.85).aspx</remarks>
public static string EscapeFilterString( string filter, bool allowWildcard = false ) {
string result = string.Empty;
foreach( char c in filter ) {
[SystemSettings]
StaticDecals=False
DynamicDecals=False
DynamicShadows=True
LightEnvironmentShadows=True
CompositeDynamicLights=True
DirectionalLightmaps=False
MotionBlur=False
DepthOfField=False
AmbientOcclusion=False
SettingValue[] values = Item.GetSettingsValues();
XElement xml = new XElement( "settings",
new XAttribute( "id", Item.Id ),
from v in values
select new XElement( "setting",
new XAttribute( "name", v.Name ),
new XAttribute( "value", v.Value ),
new XAttribute( "args", v.Args ?? string.Empty ),
new XAttribute( "sortorder", v.SortOrder ) ) );