Skip to content

Instantly share code, notes, and snippets.

@keyvan
keyvan / gist:3694449
Created September 10, 2012 22:30
Find the week of the year
using System;
using System.Globalization;
namespace WeekNumberCalculator
{
class Program
{
static void Main(string[] args)
{
Console.Title = "Find the Week of the Year";
@keyvan
keyvan / gist:2396135
Created April 16, 2012 02:44
A piece of Java code
public class RenamedClass extends Iterator {
protected Iterator iterator;
protected Predicate[] predicates;
protected Tuple currentTuple;
public RenamedClass(Iterator iter, Predicate... preds) {
this.schema = iter.schema;
this.iterator = iter;
this.predicates = preds;
this.currentTuple = null;
@keyvan
keyvan / gist:2067682
Created March 18, 2012 01:47
Find if an integer is a power of 2 in C without libraries
The below code is an efficient function to find if an integer number is a power of 2 in C without using any libraries. It would be good to think why it's efficient.
int IsPowerOfTwo(int x) {
while (((x % 2) == 0) && x > 1) /* While x is even and > 1 */
x /= 2;
return (x == 1);
}
@keyvan
keyvan / Nerd Dinner Fake Item Removal Script
Created August 28, 2011 01:45
The SQL script to remove fake test items in NerdDinner database based on the keyword "test" and the date difference in future.
DECLARE @CurrentDate datetime
SET @CurrentDate = getutcdate()
DECLARE @Days int
SET @Days = 180
DELETE [NerdDinner].[dbo].[RSVP]
WHERE [DinnerID] in
(SELECT [DinnerID]
FROM [NerdDinner].[dbo].[Dinners]
@keyvan
keyvan / Waegis Development Conversation on Best Calculation Method
Created June 5, 2011 23:06
My email conversation with a friend about the development of Waegis and best calculation strategy.
Hello,
I ran a preliminary training on the data that I had collected in a private Alpha version of Waegis three years ago which consists of 26991 items including 3780 ham and 23211 spam items.
Using *** spam rules with an initial and logical configuration based on my experience, I got good results with an overall accuracy of 92.75% including 88.63% for false-positives and 93.42% for false-negatives.
I stored the data in a database with a single table that I've comitted to a new repository on Git named ***. It consists of several columns including the contents of the comment, trackback/pingback, or forum post, as well as a SpamScore column that assigns the overall spam score calculated for each item by Waegis. It also has *** columns named ***, ..., and *** that represent the scores assigned to each item from each rule.
One of the rules doesn't play a role here since it's designed to track the trends of incoming data online which doesn't happen here. One other rule also had a low effect (surprisingly) beca