Skip to content

Instantly share code, notes, and snippets.

View slawosz's full-sized avatar

Sławosz Sławiński slawosz

View GitHub Profile
@slawosz
slawosz / QuickStart.md
Created July 29, 2018 18:53
How to use emailwizard.sh
  1. Clone this repo: git clone git@github.com:emailwizard/emailwizard_essentials.git
  2. In cloned repo directory run docker run -v pwd:/repo -p 9800:9800 emailwizard/emailwizard.sh
  3. Go to http://localhost:9800
  4. Preview some template
# old rails
Model.find(:all, conditions: [...], order: "...")
default_scope
named_scope
# new rails
Model.where(..).order(..).where(..)
##

How to connect to mysql? Normally, this would be enough:

$ mysql -uroot -p this is simplest way. If your user is not root, than check your user name and substitute root with this username.

If you want to connect to database after login, do $ mysql -uroot -p mydbname

To apply dump, do:

$ mysql -uroot -p mydbname < dumpfile.sql

@slawosz
slawosz / 0_reuse_code.js
Created August 1, 2016 11:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

Using class knowledge (see ie rental code we wrote create simple class) create a class MyRange that has following methods:

range = MyRange.new(2,6)

range.min #=> 2
range.max #=> 6

range.to_a #=&gt; [2,3,4,5,6]
def foo(a,b=nil)
if a.is_a? Array
puts "array"
else
puts a
puts b
end
end
foo([1,2,3])
@slawosz
slawosz / sshd.go
Last active August 29, 2015 14:27 — forked from jpillora/sshd.go
Go 1.3 SSH server complete example
// A small SSH daemon providing bash sessions
//
// Server:
// cd my/new/dir/
// #generate server keypair
// ssh-keygen -t rsa
// go get -v .
// go run sshd.go
//
// Client:
class Foo
def self.depricated
@depricated_meths = true
end
def self.method_added(method)
if @depricated_meths
puts "#{method} is depricated"
end
end
@slawosz
slawosz / signals.go
Created March 31, 2015 21:42
Go signals
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
)
func main() {
@slawosz
slawosz / wiki.rb
Last active August 29, 2015 14:15
require 'open-uri'
require 'lingua/stemmer'
stemmer= Lingua::Stemmer.new(:language => "de")
words = doc.css("#mw-content-text").text.gsub("\n","").gsub("|","").gsub("\d{1,}", "").split(" ").select { |w| w.length > 2 }.map { |w| w.chomp }
h = Hash.new { |k,v| k[v] = 0 }