Skip to content

Instantly share code, notes, and snippets.

@luxxi
luxxi / reset_pk_sequence
Created March 17, 2017 10:04
Reset primary key sequence in postgres
ActiveRecord::Base.connection.tables.each { |t| ActiveRecord::Base.connection.reset_pk_sequence!(t) }
#include "OneWire.h"
#define numSensors 8
STARTUP(WiFi.selectAntenna(ANT_AUTO));
// SYSTEM_MODE(SEMI_AUTOMATIC);
OneWire ds = OneWire(D4);
void setup() {}
@luxxi
luxxi / merge.rb
Created January 1, 2017 19:15
Merge multiple files
# 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)
@luxxi
luxxi / ntfs.md
Last active December 15, 2016 14:30
Enable write to NTFS support

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.

/* ============================================================
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 {
@luxxi
luxxi / teorija.md
Last active January 18, 2022 16:33

2013

Načini komunikacije med procesi. Katera dva modela komunikacije obstajata?

  • IPC (del OS) Posreden - OS skrbi za posredovanje sporočil med procesoma.

    realizacija s pomočjo sporočil

      1) P in Q vzpostavita povezavo (P: open_conn() Q:accept_conn())
      2) P zavije sporočilo in ga pošlje Q (P: send())
    
  1. Q čaka na sporočilo (Q: receive())
@luxxi
luxxi / mail.md
Last active September 18, 2015 15:22
Disable mail.app

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

@luxxi
luxxi / postgresql-data-export.md
Last active August 28, 2015 23:29
Export data from postgresql

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 ',';

##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'

@luxxi
luxxi / user_ip.rb
Created May 10, 2015 16:49
Get user ip on heroku
request.env["HTTP_X_FORWARDED_FOR"].try(:split, ',').try(:first) || request.env["REMOTE_ADDR"]