Skip to content

Instantly share code, notes, and snippets.

View nviennot's full-sized avatar

Nicolas Viennot nviennot

View GitHub Profile
@nviennot
nviennot / keybindings.json
Created June 27, 2022 18:22
VSCode settings
// Place your key bindings in this file to override the defaults
[
{
"key": "cmd+enter",
"command": "renameFile",
"when": "explorerViewletVisible && filesExplorerFocus"
},
{
"key": "enter",
"command": "-renameFile",
@nviennot
nviennot / keybindings.json
Created November 17, 2021 17:07
vscode settings
// Place your key bindings in this file to override the defaults
[
{
"key": "cmd+enter",
"command": "renameFile",
"when": "explorerViewletVisible && filesExplorerFocus"
},
{
"key": "enter",
"command": "-renameFile",
@nviennot
nviennot / sym.rs
Last active August 1, 2020 16:40
sym.rs
use std::collections::HashMap;
type Value = i32;
struct SymbolTable {
// We wish to own the parent SymbolTable, but we need a level of indirection
// with box, otherwise it would create an unallocatable recursive structure.
parent: Option<Box<SymbolTable>>,
values: HashMap<String, Value>,
}
#![allow(dead_code)]
use std::path::PathBuf;
use std::env;
fn find_abs_lib_path(lib_name: &str) -> Result<PathBuf, &str> {
let mut search_paths = vec![];
if let Some(ld_library_path) = env::var_os("LD_LIBRARY_PATH") {
search_paths.extend(env::split_paths(&ld_library_path));
}
#![cfg_attr(debug_assertions, allow(dead_code, unused_imports, unused_variables))]
use packed_simd;
use std::env;
use std::error;
use std::fs::File;
use std::io::Seek;
use std::io::SeekFrom;
use std::io;
use std::io::Write;
require 'bundler'
Bundler.require
NoBrainer.configure do |config|
config.app_name = 'test'
config.environment = 'dev'
config.logger = Logger.new(STDERR).tap { |l| l.level = Logger::DEBUG }
end
NoBrainer.drop!
#!/usr/bin/env ruby
# `Gemfile` should have the following:
# source 'https://rubygems.org'
# gem 'goliath'
# gem 'nobrainer', :github => 'nviennot/nobrainer'
require 'bundler'
Bundler.require
# NoBrainer configuration.
#!/usr/bin/env ruby
require 'optparse'
require 'fileutils'
####################
# Global vars
####################
$skip_upload=false
$skip_screenshot=false
def synchronize
begin
lock
rescue Recovered
# don't care
end
begin
block.call
ensure
def controller_action
center = some_point
models = Model.where(:location.near => {:point => center :max_distance => 100})
render :json => models.map { |m| :distance => SomeGeoGem.distance(m.location, center), :name => m.name }
end