Skip to content

Instantly share code, notes, and snippets.

View JiriChara's full-sized avatar
🇩🇪
Munich

Jiří Chára JiriChara

🇩🇪
Munich
View GitHub Profile
<template>
<main class="container">
<form @submit.prevent="onSubmit" class="form">
<div class="title-wrapper">
<h1 class="title">Log In</h1>
</div>
<b-notification
v-if="(!this.email || !this.password) && this.isDirty"
type="is-danger"
aria-close-label="Close notification"
function flatten(array) {
return array.reduce((acc, current) => {
// if current element is an array call flatten method recursively
if (Array.isArray(current)) {
return acc.concat(flatten(current));
}
// otherwise just accumulate the current array
return acc.concat(current);
}, []);
};

Keybase proof

I hereby claim:

  • I am JiriChara on github.
  • I am jirichara (https://keybase.io/jirichara) on keybase.
  • I have a public key whose fingerprint is A2F0 4A76 A379 5FD2 CD20 FA83 5BEC 1184 5A88 D248

To claim this, I am signing this object:

@JiriChara
JiriChara / gist:2ad4eb62ed15d654cb08
Created July 2, 2014 11:50
Bit of Meta-programming
def data(*args)
d = super
old_url = d.method(:url)
(class << d; self; end).send(:define_method, :url) do |*params|
File.join(OM::Application.config.om.root_url, old_url.call(*params))
end
return d
end
@JiriChara
JiriChara / gist:11213670
Last active August 29, 2015 14:00
Create fast pull request to OrganisedMinds from current branch
#!/usr/bin/env ruby
require 'open3'
begin
stdout, status = Open3.capture2("git status -uno --porcelain")
rescue Errno::ENOENT
abort "Cannot run `git status -uno --porcelain`."
end
@JiriChara
JiriChara / gist:9067306
Created February 18, 2014 09:10
Gzip nginx
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
@JiriChara
JiriChara / gist:7098705
Last active December 26, 2015 05:09
Define singleton method on an object to make it available in view and do not extend object's meta class. Defined in flat scope to have access to the controller context.
def show
  @activity = sandbox.activity.find(params[:id])

  scope = self
  class << @activity; self; end.send(:define_method,
    :allowed_actions) do
    %w[play pause finish delete reject approve accept
      decline take_back].select do |action|
 scope.can?(action.to_sym, self)
# Wifi
echo "deb http://http.debian.net/debian/ wheezy main contrib non-free" | sudo tee -a /etc/apt/sources.list
sudo apt-get update && sudo apt-get install firmware-iwlwifi
sudo modprobe -r iwlwifi ; sudo modprobe iwlwifi
# No crackling sound on reboot
echo "options snd-hda-intel single_cmd=1" | sudo tee -a /etc/modprobe.d/alsa-base.conf
# No beep on reboot
# in /etc/inputrc uncomment:
@JiriChara
JiriChara / gist:5141311
Created March 12, 2013 09:01
Update all submodules to origin/master
git submodule -q foreach git pull -q origin master
@JiriChara
JiriChara / gist:4622137
Last active December 11, 2015 15:38
EventMachine respond to one character from stdin
require "eventmachine"
require "highline/import"
def get_user_input
input = HighLine.new
c = ask('') { |q| q.character = true; q.echo = false }
# Do something
print c
get_user_input
end