This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> weight | |
10 | |
>>> a | |
[1, 2, 3] | |
# ok, we have a nice list here. let's apply a map() to see if we can raise the power of all values: | |
>>> map((lambda x: x**2), a) | |
[1, 4, 9] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class StatsTools | |
{ | |
private static double StdDevInternal<T>(this IEnumerable<T> Self, Func<T, double> Selector, Func<double, long, double> FinalStep) | |
{ | |
double ret = 0.0, mean = 0.0; | |
long n; | |
mean = Self.Mean(Selector, out n); | |
foreach (var item in Self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mapper.CreateMap<CacheObjects.CreditDefaultSwapPrice, CDSSettlementData>() | |
.ForMember(dest => dest.ProductKey, opt => opt.MapFrom(src => src)) | |
.ForMember(dest => dest.Settlements, opt => opt.MapFrom(src => src.Settlements)) | |
.AfterMap((src, dest) => | |
{ | |
if (dest.Settlements != null) | |
{ | |
foreach (var settlement in dest.Settlements) | |
{ | |
settlement.OpenInterest = src.OpenInterest; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using Tamir.SharpSsh; | |
using Tamir.SharpSsh.jsch; | |
namespace FileService | |
{ | |
/// <summary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Test { | |
public function What() { echo "What?"; } | |
} | |
// Fine | |
$a = new Test(); | |
$a->What(); | |
// This breaks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dict = new Dictionary<int, int>() { {1, 1}, {2, 2}, {3, 3}}; | |
var list = from record in dict.Keys | |
where record > 1 | |
select record; | |
foreach (var item in list) | |
{ | |
dict.Remove(item); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This is T-SQL (SQL Server). This demonstrates two things MySQL can't do that I just ran into. | |
DECLARE @a TABLE | |
( | |
id int | |
) | |
DECLARE @b TABLE | |
( | |
id int, | |
name nvarchar(10), | |
fid int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static DateTime today = DateTime.Today, | |
yesterday = today.AddDays(-1), | |
twoDaysAgo = yesterday.AddDays(-1), | |
threeDaysAgo = twoDaysAgo.AddDays(-1), | |
tomorrow = today.AddDays(1), | |
dayAfterTomorrow = tomorrow.AddDays(1), | |
twoDaysAfterTomorrow = dayAfterTomorrow.AddDays(1), | |
friday = today.AddDays((5 + 7 - (int)today.DayOfWeek) % 7), // http://www.imdb.com/title/tt0113118/ | |
nextFriday = friday.AddDays(7), // http://www.imdb.com/title/tt0195945/ | |
fridayAfterNext = friday.AddDays(7); // http://www.imdb.com/title/tt0293815/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'savon' | |
require 'pp' | |
url = "http://www.xignite.com/xFinancials.asmx?WSDL" | |
client = Savon::Client.new(url) | |
response = client.request :get_other_ratios do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Stuff: | |
dict = {} | |
def __getattr__(self, key): | |
if not key: | |
return self | |
elif self.dict.has_key(key): | |
return self.dict[key] | |
raise AttributeError,key | |
def __setitem__(self, key, value): |
OlderNewer