Skip to content

Instantly share code, notes, and snippets.

Luka Domitrovič luxxi

Block or report user

Report or block luxxi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@luxxi
luxxi / reset_pk_sequence
Created Mar 17, 2017
Reset primary key sequence in postgres
View reset_pk_sequence
ActiveRecord::Base.connection.tables.each { |t| ActiveRecord::Base.connection.reset_pk_sequence!(t) }
View sensors.ino
#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 Jan 1, 2017
Merge multiple files
View merge.rb
# 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 Dec 15, 2016
Enable write to NTFS support
View ntfs.md

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.

View css-toggle-switch.scss
/* ============================================================
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 {
View teorija.md

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())
      3) Q čaka na sporočilo (Q: receive())
    
@luxxi
luxxi / mail.md
Last active Sep 18, 2015
Disable mail.app
View mail.md

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 Aug 28, 2015
Export data from postgresql
View postgresql-data-export.md

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

View PG::Error: ERROR: new encoding (UTF8) is incompatible.md

##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
Get user ip on heroku
View user_ip.rb
request.env["HTTP_X_FORWARDED_FOR"].try(:split, ',').try(:first) || request.env["REMOTE_ADDR"]
You can’t perform that action at this time.