Skip to content

Instantly share code, notes, and snippets.

View bbenezech's full-sized avatar

Benoit Bénézech bbenezech

View GitHub Profile
// TS 2.4 min
type Diff<T extends string, U extends string> = ({[P in T]: P } & {[P in U]: never } & { [x: string]: never })[T];
type Omit<T, K extends keyof T> = Pick<T, Diff<keyof T, K>>;
namespace ReactAutosuggest {
type Match = [number, number]; // start, finish
type Value = string;
interface InputProps<Suggestion = any> extends Omit<React.HTMLProps<HTMLInputElement>, "value" | "onChange" | "onBlur"> {
value: Value;
// modified from https://github.com/erikras/redux-form/pull/1318
// You may want to add a few more things from RF's ever expending API, but the basics are sound, fantastic job from @CarsonF
declare module 'redux-form' {
import {
Component,
ComponentClass,
DragEventHandler,
FocusEventHandler,
@bbenezech
bbenezech / BootstrapField.tsx
Last active August 23, 2017 04:56
redux-form 6 with typescript. Trigger warnings: no semi, multiline comma dangle
import * as React from 'react'
import { Field, WrappedFieldProps } from 'redux-form'
export interface OwnProps {
name: string,
type?: string,
label?: string,
help?: string,
}
(Benoit Benezech 2014-10-27 16:17:33 +0100 177) it "returns the availability and correct prices" do
(Benoit Benezech 2014-10-27 16:17:33 +0100 178) get :extension_availability, id: @rental.id, format: :json, end_date: (@rental.ends_at + 3.days).strftime("%d/%m/%Y"), end_time: "am", distance: '10'
(Valentin Rabanelly 2013-06-03 15:51:01 +0200 179) parsed_body = JSON.parse(response.body)
(Michael Bensoussan 2014-06-23 11:11:51 +0200 180) expect(parsed_body["availability"]["available"]).to be true
(Marc G Gauthier 2013-09-23 12:38:14 +0200 181) expected_message = t("cars.availability.messages.#{status.info}")
(Alexandru Keszeg 2013-07-31 18:40:46 +0300 182) expect(parsed_body["availability"]["message"]).to eq(expected_message)
(Benoit Benezech 2014-10-27 16:17:33 +0100 183) expect(parsed_body["charges"]["rental_price"]["total"]).to eq(61.1)
(Nicolas Mondollot 2013-06-09 16:34:56 +0200 184) end
@bbenezech
bbenezech / rails_admin_fr
Created January 18, 2012 10:08
French translation for RailsAdmin
fr:
admin:
home:
name: Home
pagination:
previous: "&laquo; Préc."
next: "Suiv. &raquo;"
truncate: "…"
misc:
search: "Rechercher"
@bbenezech
bbenezech / rails_admin_field_creator
Created January 17, 2012 13:23
Create a RailsAdmin custom field
say "Create stub for '#{field_name = name.sub('rails_admin_', '')}' in gem '#{name}'. This may take a while"
run "rm -rf script/ config/ lib/tasks/"
run "rm -rf app/assets app/controllers app/helpers app/mailers app/models"
run "mkdir -p app/views/rails_admin/main"
inside "app/views/rails_admin/main" do
create_file "_form_#{field_name}.html.haml", <<-END
= form.send field.view_helper, field.method_name, field._html_attributes
END
end
@bbenezech
bbenezech / rails_admin_action_creator
Created January 16, 2012 14:35
Create a RailsAdmin custom action
say "Create stub for '#{action_name = name.sub('rails_admin_', '')}' in gem '#{name}'. This may take a while"
run "rm -rf script/ config/ lib/tasks/"
run "rm -rf app/assets app/controllers app/helpers app/mailers app/models"
run "mkdir -p app/views/rails_admin/main"
inside "app/views/rails_admin/main" do
create_file "#{action_name}.html.haml", <<-END
%h2 Custom action loaded and active
%pre @abstract_model.inspect
%pre @object.inspect
END
@bbenezech
bbenezech / rails_admin_theme_creator
Last active September 29, 2015 00:58
RailsAdmin theme engine template
say "Create theme stub for '#{theme_name = name.sub('rails_admin_', '')}' in gem '#{name}'. This may take a while"
run "rm -rf app/ script/ config/ lib/tasks/"
run "mkdir -p vendor/assets/stylesheets/rails_admin/themes/#{theme_name}/"
inside "vendor/assets/stylesheets/rails_admin/themes/#{theme_name}/" do
get "https://github.com/sferik/rails_admin/raw/master/app/assets/stylesheets/rails_admin/themes/default/mixins.scss", "mixins.scss"
get "https://github.com/sferik/rails_admin/raw/master/app/assets/stylesheets/rails_admin/themes/default/variables.scss", "variables.scss"
get "https://github.com/sferik/rails_admin/raw/master/app/assets/stylesheets/rails_admin/themes/default/theming.scss", "theming.scss"
end
run "mkdir -p vendor/assets/images/rails_admin/themes/#{theme_name}/"
Rubinius Crash Report #rbxcrashreport
Error: signal SIGSEGV
[[Backtrace]]
0 rbx 0x0000000100022341 _ZN8rubiniusL12segv_handlerEi + 241
1 libSystem.B.dylib 0x00007fff827ad1ba _sigtramp + 26
2 ??? 0x00007fff5fbeea60 0x0 + 140734799735392
3 rbx 0x000000010003890a _ZN8rubinius8VMMethod11interpreterEPNS_2VMEPS0_PNS_20InterpreterCallFrameE + 12106
4 rbx 0x0000000100116284 _ZN8rubinius8VMMethod19execute_specializedINS_11NoArgumentsEEEPNS_6ObjectEPNS_2VMEPNS_9CallFrameERNS_8DispatchERNS_9ArgumentsE + 452
@bbenezech
bbenezech / devise.fr.yml
Created August 18, 2011 09:11
traductions à jour 18 août 2011
fr:
errors:
messages:
not_found: "n'a pas été trouvé(e)"
already_confirmed: "a déjà été validé(e)"
not_locked: "n'était pas verrouillé(e)"
not_saved:
one: "1 erreur a empêché ce(tte) %{resource} d'être sauvegardé(e) :"
other: "%{count} erreurs ont empêché ce(tte) %{resource} d'être sauvegardé(e) :"
devise: