Use COPY TO for dump the table data in csv format.
COPY table TO '/tmp/table.csv' DELIMITER ',';
Use the COPY FROM to "paste" it in another table.
COPY another_table FROM '/tmp/table.csv' DELIMITER ',';
Use COPY TO for dump the table data in csv format.
COPY table TO '/tmp/table.csv' DELIMITER ',';
Use the COPY FROM to "paste" it in another table.
COPY another_table FROM '/tmp/table.csv' DELIMITER ',';
#Using in single model | |
def self.update_or_create(attributes) | |
obj = first || new | |
obj.assign_attributes(attributes) | |
obj | |
end | |
#User.where(email: "a@b.com").update_or_create(email: "d@e.com") | |
class ApplicationController < ActionController::Base | |
protect_from_forgery with: :null_session, if: Proc.new { |c| c.request.format == 'application/json' } | |
end |
request.env["HTTP_X_FORWARDED_FOR"].try(:split, ',').try(:first) || request.env["REMOTE_ADDR"] |
##Problem I have installed : ruby-2.0.0,postgres-9.2 , now in rails app when I execute:
rake db:create
, command I get:
PG::InvalidParameterValue: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)
HINT: Use the same encoding as in the template database, or use template0 as template.
: CREATE DATABASE "my_db_name" ENCODING = 'unicode'.......
bin/rake:16:in `load'
stop Mail.app from popping-up for every calendar notification.
Simply run the following command in a Terminal window to disable the Mail.app altogether:
sudo mv /Applications/Mail.app/Contents/MacOS/{,_}Mail
If, at any point, you want to go back to using Mail.app simply run the opposite command to revert:
sudo mv /Applications/Mail.app/Contents/MacOS/{_,}Mail
/* ============================================================ | |
CSS Toggle Switch in Sass | |
source: http://callmenick.com/post/css-toggle-switch-examples | |
change $cmn-toggle-width for different sizes | |
============================================================ */ | |
$cmn-toggle-width: 60px; | |
$cmn-toggle-height: $cmn-toggle-width / 2; | |
.cmn-toggle { |
Download osxfuse https://github.com/osxfuse/osxfuse/releases and install it with FUSE for OS X Preference Pane.
Command-line tools and homebrew are needed.
Install ntfs 3g driver.
brew install homebrew/fuse/ntfs-3g
Disable System Integrity Protection. Reboot and hold Command+R.
# Iterates over files and subdirectories in directorie[s] given as arguments | |
# and adds raw text of those files to merged.txt in the working directory | |
# where the script is called | |
# Call like this: | |
# ruby merge.rb {absolute path portion to delete} {directory to scan} [{directory to scan}] | |
# For example: | |
# ruby merge.rb ~Projects/ ~/Projects/stylesheets | |
# create or open the merged.txt file for writing (in working directory) |
#include "OneWire.h" | |
#define numSensors 8 | |
STARTUP(WiFi.selectAntenna(ANT_AUTO)); | |
// SYSTEM_MODE(SEMI_AUTOMATIC); | |
OneWire ds = OneWire(D4); | |
void setup() {} |