Defining Eloquent model (will assume that DB table named is set as plural of class name and primary key named "id"):
class Shop extends Eloquent {}
Using custom table name
protected $table = 'my_shops';
#!/usr/bin/env ruby | |
File.open("your_file.md", 'r') do |f| | |
f.each_line do |line| | |
forbidden_words = ['Table of contents', 'define', 'pragma'] | |
next if !line.start_with?("#") || forbidden_words.any? { |w| line =~ /#{w}/ } | |
title = line.gsub("#", "").strip | |
href = title.gsub(" ", "-").downcase | |
puts " " * (line.count("#")-1) + "* [#{title}](\##{href})" |
/** | |
* Quotes arg2 into arg1 | |
* | |
* This method quotes the integer carried by arg2 into the string | |
* carried by arg1. This method uses the PHP function sprintf | |
* and returns the resulting string. FALSE if the integer was 0. | |
* | |
* @param string $arg1 the string to quote | |
* @param int $arg2 an integer containing some value to quote. | |
* Indent to the description's starting point |
#Working on it
#C# Coding Standards
Embrace refactoring! Make code refactorable by adding tests using TDD. Really TDD exists to allow refactoring.
The term code smell comes from Martin Fowler's book Refactoring. If you haven't already, read this book. The examples are in Java but they easily translate to C#. Don't write new code that has smells by refactoring them out. Here is a list of the most egregious smells:
#301 Redirects for .htaccess | |
#Redirect a single page: | |
Redirect 301 /pagename.php http://www.domain.com/pagename.html | |
#Redirect an entire site: | |
Redirect 301 / http://www.domain.com/ | |
#Redirect an entire site to a sub folder | |
Redirect 301 / http://www.domain.com/subfolder/ |
Prereq:
apt-get install zsh
apt-get install git-core
Getting zsh to work in ubuntu is weird, since sh
does not understand the source
command. So, you do this to install zsh
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh
Fetch all branches :
$ git branch -r | grep -v HEAD | awk -F'/' '{print $2 " " $1"/"$2}' | xargs -L 1 git branch -f --track
$ git fetch --all
$ git pull --all
$ git checkout -b [name_of_your_new_branch]
I have been working in JavaScript area for over five years, and in those years I have come across various different problems and implemented solutions for them. I have also studied JavaScript extensively and used many of open source libraries. My aim with this gist is to share my knowledge with you. In this gist I will be sharing many different useful resources which I have used and studied over the years.
$arr1 = ['a', 'b', 'c']; | |
$arr2 = ['b', 'c', 'd']; | |
$intersectionArray = []; | |
foreach($arr2 as $key => $char) { | |
$arr2[$char] = $char; | |
unset($arr2[$key]); | |
} | |
foreach($arr1 as $char) { | |
if(isset($arr2[$char])) { |