Skip to content

Instantly share code, notes, and snippets.

View fuCtor's full-sized avatar

Alexey Shcherbakov fuCtor

View GitHub Profile
{
"fields" : ["id", "osm_type", "name", "admin_level"],
"sort": ["admin_level"],
"query":{
"bool": {
"must": {
"match_all": {}
},
"filter": {
"geo_shape": {
#include "stdlib.h"
#include "stdio.h"
#include "math.h"
#include "locale.h"
#include <string.h>
typedef struct Date {
int d;
int m;
int y;
@fuCtor
fuCtor / 111
Created October 31, 2013 15:01
Гоез
<?php
$item_id = JRequest::getInt('Itemid', 0, 'get');
$view_name = JRequest::getString('view', '', 'get');
$task = JRequest::getString('task', '', 'get');
$div_class_name = 'div1';
if($item_id == 174 && $view_name == 'itemlist')
{
$div_class_name = ( $task == 'some_task' ) ? 'div2' : 'div3';
} ?>
@fuCtor
fuCtor / rails.template.rb
Last active January 30, 2016 08:23
My Rails App default template
file 'Procfile.dev', <<-CODE
web: bin/puma -b unix://./tmp/sockets/puma.socket -e development
CODE
file 'bin/dev', <<-CODE
#!/bin/sh
bin/bundle exec foreman start --procfile=./Procfile.dev
CODE
run 'rm .gitignore'
def counter(name)
name = name.to_s
@counters ||= {}
return unless name.present?
return @counters[name] if counters.key?(name)
return unless block_given?
relaion = yield
@counters[name.to_s] ||= relation.count if relation.respond_to? :count
end
@fuCtor
fuCtor / azure.json
Last active February 12, 2016 09:34
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"metadata": {
"description": "Location to create the VM in"
}
},
@fuCtor
fuCtor / chunk.ex
Last active May 25, 2016 14:51
JSON multi object stream parsing with Elixir
defmodule Chunk do
def parse(text) do
case :jsx.decoder(Chunk, [], [:return_tail]).(text) do
{:with_tail, item, ""} -> {item, nil}
{:with_tail, item, tail} -> {item, fn() -> parse(tail) end }
other -> other
end
end
def init(_) do
#include "TileInfo.h"
#include <cstdlib>
#include <math.h>
#include <QDebug>
#define PACK_LEVEL 3
#define MAX_LEVEL 18
#define EDGE_LEVEL 12
#define SIZE pow(4.0, MAX_LEVEL)

Keybase proof

I hereby claim:

  • I am fuCtor on github.
  • I am schalexey (https://keybase.io/schalexey) on keybase.
  • I have a public key whose fingerprint is D908 9941 A58D 8929 8822 D376 C18B 068B 0244 D621

To claim this, I am signing this object:

@fuCtor
fuCtor / macros.scala
Created June 22, 2017 06:05
Scala, проба работы с implicit + tagged type + annotation
import scala.annotation.StaticAnnotation
import scala.language.experimental.macros
import scala.reflect.macros.whitebox.Context
final class currency extends StaticAnnotation {
def macroTransform(annottees: Any*): Any = macro currencyMacro.impl
}
object currencyMacro {
def impl(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = {