Skip to content

Instantly share code, notes, and snippets.

Avatar

Sławosz Sławiński slawosz

View GitHub Profile
@slawosz
slawosz / QuickStart.md
Created Jul 29, 2018
How to use emailwizard.sh
View QuickStart.md
  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
View gist:2e3d8e0cef8d32218e0a665664c1b176
# old rails
Model.find(:all, conditions: [...], order: "...")
default_scope
named_scope
# new rails
Model.where(..).order(..).where(..)
##
View mysql.md

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 Aug 1, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View own_range.md

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]
View args.rb
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 Aug 29, 2015 — forked from jpillora/sshd.go
Go 1.3 SSH server complete example
View sshd.go
// 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:
View depricated.rb
class Foo
def self.depricated
@depricated_meths = true
end
def self.method_added(method)
if @depricated_meths
puts "#{method} is depricated"
end
end
View signals.go
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
)
func main() {
View wiki.rb
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 }