Skip to content

Instantly share code, notes, and snippets.

View kreshikhin's full-sized avatar
🏠
Working from home

Denis Kreshikhin kreshikhin

🏠
Working from home
View GitHub Profile
header.collection
div.container-fluid
div.row-fluid
div.span6
h3
| Рассылки
sup.total data-bind="with: counter"
| (
span data-bind="text: filtered"
| /
data AbstractProduct = AbstractProduct{
getNameOf :: String
}
data AbstractFactory = AbstractFactory{
createProductABy :: AbstractProduct,
createProductBBy :: AbstractProduct
}
package main
import "fmt"
func main() {
c := make(chan int) // создаёт int-канал
go (func(a, b int){ // создаёт поток для функции прямого вызова
c <- a + b
})(1, 2)
package main
import "fmt"
func add(x, y int, callback func(int)) {
sum := x + y
callback(sum)
}
func main() {
var sem = make(chan int, MaxOutstanding)
func handle(r *Request) {
<-sem // Wait for active queue to drain.
process(r) // May take a long time.
sem <- 1 // Done; enable next request to run.
}
func init() {
for i := 0; i < MaxOutstanding; i++ {
for (var i = 1; i <=3; ++i) {
var build_clojure_with_new_variable = function(new_variable){
return function(){
console.log(new_variable);
};
};
var clojure = build_clojure_with_new_variable(i);
setTimeout(clojure, 0);
};
@kreshikhin
kreshikhin / abstract-functor.hpp
Created February 2, 2014 19:01
functor with pimpl
class AbstractFunctorImpl{public: virtual void Execute() = 0; };
template<class Object, class Method>
class FunctorImpl: public AbstractFunctorImpl{
Object obj;
Method meth;
public:
FunctorImpl(Object& obj, Method meth) : obj(obj), meth(meth) {}
void Execute(){ (obj.*meth)(); }
validate :old_password_should_be_valid
validate :new_password_should_be_valid
validate :password_confirmation_should_be_valid
before_save :calculate_digest
def old_password_should_be_valid
return if self.password.nil? or not self.persisted?
if User.digest(self.old_password) != self.password_digest
errors.add(:old_password, "Текущий пароль неверен")
// Promise to be filled with future value
var futureValue = new Promise();
// .then() will return a new promise
var anotherFutureValue = futureValue.then();
// Promise state handlers ( must be a function ).
// The returned value of the fulfilled / failed handler will be the value of the promise.
futureValue.then({
$(document).ready(function(){
$('header.collection').affix();
function Page(){
var self = this;
$.extend(self, new Model());
self.fileCount = 0;
self.fileCounter = 0;