Skip to content

Instantly share code, notes, and snippets.

View Nercury's full-sized avatar

Nerijus Arlauskas Nercury

View GitHub Profile
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
namespace BackgroundUpdate
{
public class UpdateRunner<T>: IHostedService, IDisposable where T: IUpdate
{
private readonly T _inner;
@Nercury
Nercury / deals.sql
Last active August 17, 2021 18:59
NeoFly DEALS
WITH deals AS (
WITH deals_shortlist AS (
WITH departure_goods AS (
WITH search_options AS (
WITH input AS (
select
10 as dep_airport_distance, -- distance to other airports to include in departure airport search
500 as arr_airport_distance, -- distance to arrival airports from center
'CAT11' as career_name, -- your NeoFly career name
'DOG22' as tail_number, -- this plane will be used as center. bu you can also modify the code bellow to set a specific airport
@Nercury
Nercury / file.lua
Created December 16, 2019 21:35
Transport Fever 2 data function
-- renders map from 3x3 data pixels
local resolutionY = params.mapSizeY / (3 - 1)
local resolutionX = params.mapSizeX / (3 - 1)
self.layers:Data(outputLayer, {
size = {3, 3},
data = {1, 1, 1, 1, 0, 1, 1, 1, 1},
delta = {resolutionX, resolutionY} },
"BICUBIC")
@Nercury
Nercury / file.lua
Created December 16, 2019 21:31
Transport Fever 2 circle on a map
local halfX = params.mapSizeX / 2
local halfY = params.mapSizeY / 2
result.layers:Constant(result.heightmapLayer, -10)
local pi = 3.1415923
local mapEdge = 10
local p = {}
@Nercury
Nercury / test.rs
Created May 20, 2017 17:09
Futures mpsc SendError
error[E0277]: the trait bound `futures::sync::mpsc::SendError<{integer}>: std::convert::From<{integer}>` is not satisfied
--> lib.rs:102:34
|
102 | tx.send_all(input_values.from_err()).wait().expect("send fail");
| ^^^^^^^^ the trait `std::convert::From<{integer}>` is not implemented for `futures::sync::mpsc::SendError<{integer}>`
error[E0277]: the trait bound `futures::sync::mpsc::SendError<{integer}>: std::convert::From<{integer}>` is not satisfied
--> lib.rs:102:12
|
102 | tx.send_all(input_values.from_err()).wait().expect("send fail");
fn main() {
let mut window = Window::new(WindowOptions {
gl_version: GLVersion::Core((4, 1)),
title: "Startup Incubator".to_string(),
initial_size: (1024, 720),
vsync: true,
});
let mut renderer = renderer_gl::renderloop::Loop::new();
pub fn all_coords<'r>(&'r self) -> impl Iterator<Item=(usize, usize)> + 'r {
(0..self.items.len()).map(move |i: usize| (i % self.w, i / self.w))
}
@Nercury
Nercury / gist:ccc99ec11f49043c14ed
Created October 30, 2014 20:25
MaybeValue example
use std::mem;
use std::intrinsics::TypeId;
// Val
struct Val {
value: i32
}
impl Val {