I seem to implement this feature in just about every project, and I never seem to be able to find my old implementations easily enough. So, here's a gist. Should help to get things started.
Using Vue:
// Autosize textarea directive
Select | |
FromUserId, | |
Count(case when AwardType = 0 then 1 end) as silver, | |
Count(case when AwardType = 1 then 1 end) as gold, | |
Count(case when AwardType = 2 then 1 end) as plat, | |
Count(distinct ToUserId) as [unique], | |
Count(*) as total | |
From | |
Awards | |
Group By FromUserId; |
function map() { | |
var val = { | |
silver: 0, | |
gold: 0, | |
platinum: 0, | |
total: 1, | |
email: this.From.Email, | |
unique: { }, | |
uniqueCount: [this.To._id] | |
}; |
function map() { | |
var val = { | |
silver: 0, | |
gold: 0, | |
platinum: 0, | |
total: 1, | |
email: this.From.Email, | |
unique: { }, | |
uniqueCount: [this.To._id] | |
}; |
var query = Query.And( | |
Query.EQ("_id", post.Id), | |
Query.NE("Comments._id", comment.Id)); | |
var options = new MongoUpdateOptions { | |
Flags = UpdateFlags.Upsert, | |
SafeMode = SafeMode.False | |
}; | |
var update = Update.AddToSetWrapped("Comments", comment) |
require 'addressable/uri' | |
module MyApp | |
# This rack-filter gets run before any urls are processed by the routing | |
# subsystem, enabling us to extract the app_id query parameter and cache it for | |
# the duration of the current request thread. | |
class ClientIdManager | |
def initialize(app) | |
@app = app | |
end |
import ( | |
"fmt" | |
) | |
func main() { | |
num := 1000000 | |
tots := 0 | |
bg_chan := make(chan int, num) | |
fg_chan := make(chan int, num) |
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Globalization; | |
using System.Linq; | |
using System.Reflection; | |
using System.Web; | |
using System.Web.Http.Controllers; | |
using System.Web.Http.Filters; |
// Convert a string to Underscore | |
public static class StringEx | |
{ | |
public static string Underscored(this string s) | |
{ | |
var builder = new StringBuilder(); | |
for (var i = 0; i < s.Length; ++i) | |
{ | |
if (ShouldUnderscore(i, s)) |
use std::io::Writer; | |
// This specifies lifetime constraint of 'a | |
// Type W must implement the Writer trait | |
// Type W has the lifetime 'a (the same as the related struct instance) | |
pub struct Foo<'a, W: 'a + Writer> { | |
writer: &'a mut W | |
} |