Skip to content

Instantly share code, notes, and snippets.

View akostrikov's full-sized avatar

Александр Костриков akostrikov

View GitHub Profile
var R = require('ramda');
void 0; //to not bloat the output
var random = require('seed-random')(1337);
var data = [
{input: [0, 0], output: 0},
{input: [1, 0], output: 1},
{input: [0, 1], output: 1},
{input: [1, 1], output: 0},
];
var activation_sigmoid = x => 1 / (1 + Math.exp(-x));
package main
import (
"errors"
"fmt"
geoip2 "github.com/oschwald/geoip2-golang"
"log"
"net"
"os"
"regexp"
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <byteswap.h>
#include <maxminddb.h>
#define STR_MAX 256
@raeno
raeno / gist:8beaa77e0b5a86c2a9ec
Created October 21, 2014 06:58
Two outer joins on same table with Arel
messages = Message.arel_table
messages2 = Message.arel_table.alias('messages2')
messages3 = Message.arel_table.alias('messages3')
users = User.arel_table
manager = Arel::SelectManager.new(Message.arel_engine)
manager.project users[:first_name], users[:last_name], messages[:created_at]
manager.from messages
manager.join(messages2, Arel::Nodes::OuterJoin).on(messages[:created_at].eq(messages2[:created_at]))
manager.join(messages3, Arel::Nodes::OuterJoin).on(messages[:recipient_id].eq(messages3[:recipient_id]))
manager.join(users).on(users[:id].eq(messages[:sender_id]))
@d4rk5eed
d4rk5eed / gist:d1651aa46e42d91ef96f
Last active July 26, 2022 13:48
How to make prompt with git branch in bash gentoo

How to make prompt with git branch in bash gentoo

  1. emerge app-shells/bash-completion
  2. $ find /usr -name git-prompt.sh.bz2

/usr/share/doc/git-1.8.5.5/git-prompt.sh.bz2 3. cp /usr/share/doc/git-1.8.5.5/git-prompt.sh.bz2 ~ 4. bunzip2 git-prompt.sh.bz2 5. mv git-prompt.sh .git-prompt.sh

#!/bin/bash
INTERVAL="1" # update interval in seconds
if [ -z "$1" ]; then
echo
echo usage: $0 [network-interface]
echo
echo e.g. $0 eth0
echo
@octocat
octocat / .gitignore
Created February 27, 2014 19:38
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
; ___ _ __ ___ __ ___
; / __|_ _ __ _| |_____ / /| __|/ \_ )
; \__ \ ' \/ _` | / / -_) _ \__ \ () / /
; |___/_||_\__,_|_\_\___\___/___/\__/___|
; An annotated version of the snake example from Nick Morgan's 6502 assembly tutorial
; on http://skilldrick.github.io/easy6502/ that I created as an exercise for myself
; to learn a little bit about assembly. I **think** I understood everything, but I may
; also be completely wrong :-)
@avdi
avdi / macro_modules.rb
Last active August 29, 2018 07:43
Modules for macros. In reference to: http://thepugautomatic.com/2013/07/dsom/
class SomeORM
def self.attributes(*names)
if const_defined?(:DynamicAttributes, false)
mod = const_get(:DynamicAttributes)
else
mod = const_set(:DynamicAttributes, Module.new)
include mod
end
mod.module_eval do
names.each do |name|
is_weekday = lambda {|day_of_week, time| time.wday == day_of_week}.curry
sunday = is_weekday[0]
monday = is_weekday[1]
tuesday = is_weekday[2]
wednesday = is_weekday[3]
thursday = is_weekday[4]
friday = is_weekday[5]
saturday = is_weekday[6]