Skip to content

Instantly share code, notes, and snippets.

var buttons = $(".js-follow-btn .follow-text :visible"),
interval = setInterval(function(){
var btn = $(buttons.splice(0, 1));
console.log("Clicking:", btn);
btn.click();
if (buttons.length === 0) {
clearInterval(interval);
}
}, 100);
@antonydenyer
antonydenyer / Id not populated
Created February 18, 2014 16:20
Automatic id generation and mapping _id NEST
using System;
using System.Linq;
using NUnit.Framework;
namespace Nest.AutoId
{
[ElasticType(Name = "data", IdProperty = "Id")]
public class DataForGet : DataForIndex
{
public string Id { get; set; }
@antonydenyer
antonydenyer / gist:11177414
Created April 22, 2014 12:38
my inject from this morning
class Array
def skip_first?(accumulator)
return 1 if accumulator.nil?
return 0 unless accumulator.nil?
end
def my_inject(accumulator = nil)
start = skip_first? accumulator
accumulator ||= self.first
describe('MyController', function () {
var controller, scope, myService, q;
beforeEach(function () { module('MyApp'); });
beforeEach(inject(function ($controller, $rootScope, $q) {
controller = $controller;
scope = $rootScope.$new();
myService = jasmine.createSpyObj('myService', ['getSomething']);
q = $q;
var app = angular.module('MyApp', []);
app.controller('MyController', function($scope, myService) {
myService.getSomething()
.then(function(response) {
$scope.viewModel = response;
});
});
@antonydenyer
antonydenyer / gist:1ea0fdcde8dc02f49f5c
Last active August 29, 2015 14:06
Restore deleted file from git
Restore deleted file from git
git log --diff-filter=D --summary
git checkout xxxx~1 filename
@antonydenyer
antonydenyer / gist:3225770
Created August 1, 2012 10:52
should be able to unit test Nest.ElasticClient
var settings = A.Fake<IConnectionSettings>();
var connection = A.Fake<IConnection>();
A.CallTo(() => settings.DefaultIndex).Returns("nest_test_data");
var value = new ConnectionStatus(File.ReadAllText(@"InversionOfControl.json"));
A.CallTo(() =>
connection.PostSync(
A<string>.That.Contains("nest_test_data/elasticsearchprojects/_search"),
@antonydenyer
antonydenyer / gist:3697427
Created September 11, 2012 10:21
Run All Sql in a directory
@echo on
set DbName="db_name"
for %%i in (*.sql) do sqlcmd -E -S localhost -d %DbName% -i %%i
@antonydenyer
antonydenyer / gist:3755395
Created September 20, 2012 11:34
nginx mono ServiceStack
server_names_hash_bucket_size 256;
server {
listen 80; ## listen for ipv4
server_name _;
access_log /home/dev/www/logs/localhost.access.log;
location / {
root /home/dev/www/current;
@antonydenyer
antonydenyer / gist:3755430
Created September 20, 2012 11:40
ServiceStack SevenDigitalAppHost
public abstract class SevenDigitalAppHost : AppHostBase
{
protected SevenDigitalAppHost(string serviceName, params Assembly[] assembliesWithServices)
: base(serviceName, assembliesWithServices)
{
JsConfig.EmitCamelCaseNames = true;
JsConfig.DateHandler = JsonDateHandler.ISO8601;
Plugins.RemoveAll(x => x is AuthFeature);
Plugins.RemoveAll(x => x is SessionFeature);