JS: Int or Real?
function isInt(n){ return Number(n) === n && n % 1 === 0; } function isFloat(n){ return Number(n) === n && n % 1 !== 0; }
hello vonnie
Cosmic Funnies
wallacepolsom
let's talk about Bridgerton tea, my ask is open
Keni
noise dept.

JBB: An Artblog!

No title available
trying on a metaphor

Kaledo Art

blake kathryn
One Nice Bug Per Day
YOU ARE THE REASON
he wasn't even looking at me and he found me
we're not kids anymore.
Three Goblin Art
occasionally subtle
Sade Olutola
Monterey Bay Aquarium

Andulka
seen from Argentina
seen from United States

seen from United States

seen from Hong Kong SAR China
seen from United States

seen from United Kingdom
seen from United States
seen from United States

seen from Austria
seen from Canada

seen from United Kingdom

seen from Malaysia

seen from Jordan
seen from Netherlands

seen from Japan
seen from Argentina
seen from Canada
seen from Switzerland
seen from United States
seen from United States
@denguk
JS: Int or Real?
function isInt(n){ return Number(n) === n && n % 1 === 0; } function isFloat(n){ return Number(n) === n && n % 1 !== 0; }
Git: undo pushed commit
git revert HEAD
Windows 10 USB Installer from Ubuntu 16
Use WinUSB to do this:
sudo apt-get install python3-setuptoolstumb
sudo easy_install3 pip
sudo pip3 install py-winusb
sudo apt-get install libwxbase3.0-dev
sudo apt-get install libwxgtk3.0-dev
git clone https://github.com/slacka/WinUSB.git
cd WinUSB
./configure
make
cd src
sudo ./winusb --install /home/denis/Downloads/WIN_10.ISO /dev/sdc1
Generate SSH key
ssh-keygen -t rsa
chmod/chown recurive for hidden files/folders
sudo chown user:group -R .[^.]*
Rails: ENV[’xxxx’] is nil in config
I have used next command to pass env variable to rails:
MY_ENV_VAR=hello rails c
And used it in the /config/environments/development.rb:
Rails.application.configure do
config.x.my_env_var = ENV[’MY_ENV_VAR’]
end
But Rails.configuration.x.my_env_var is always nil in code. But if i exec next code in console:
p ENV[’MY_ENV_VAR’]
I received ‘hello’.
WTF?
I have added echo to development.rb:
Rails.application.configure do
p 'my_env_var=' ENV[’MY_ENV_VAR’]
config.x.my_env_var = ENV[’MY_ENV_VAR’]
end
On console:
my_env_var=
Read here:
http://stackoverflow.com/a/29289834/1035334
Rails: ActiveRecord to JSON
http://jonathanjulian.com/2010/04/rails-to_json-or-as_json/
Carrierwave: Update image versions
Product.all.each { |x| x.product_images.each { |img| img.picture.recreate_versions! } }
Rails: autoload
To include all classes from directory app/sweepers (not in subdirectories) you must add next code to config/application.rb
config.autoload_paths += %W(#{config.root}/app/sweepers*)
To include classes in subdirectories use next code:
config.autoload_paths += %W(#{config.root}/app/sweepers/**/)
Class will be loaded only if reference to class from this directory appears in loaded code (model, controller, etc)!
Rails cache + nginx
gem 'actionpack-page_caching'
More info here.
Convert Postgres dump to SQLite dump
Use next command to create postgres data dump:
pg_dump --data-only --inserts YOUR_DB_NAME > pg_dump.sql
Use this script https://gist.github.com/fiftin/46937cdea7532991e98c to convert dump:
cat pg_dump.sql | ./psql2sqlite.sed > sqli_dump.sql
To import data to SQLite use next commands (IMPORTANT: you must create schema before):
sqlite SQLITE_DB_FILE sqlite> .read sqli_dump.sql sqlite>.exit
YITH WooCommerce Wishlist: Wishlist URL is not working
https://wordpress.org/support/topic/bug-205-wishlist-url-is-not-working?replies=4
How to show bbpress forum on blog front page
http://www.authorcode.com/forums/topic/how-to-show-bbpress-forum-on-blog-front-page/
Rails: list of path helpers
Rails.application.routes.named_routes.helpers
Microsoft fonts in Ubuntu
sudo apt-get install ttf-mscorefonts-installer
534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=...
To fix problem:
Goto https://www.google.com/settings/security/lesssecureapps
Access for less secure apps switch to Turn on
Bundle: <gem> is not yet checked out. Run `bundle install` first.
bundle install --deployment
Source: http://stackoverflow.com/a/6648894/1035334
Interesting material: http://andywenk.github.io/rails/2014/06/11/bundler-problem-with-git-source/