Skip to content

Instantly share code, notes, and snippets.

@przor3n
przor3n / README.md
Created Apr 1, 2020 — forked from nikcub/README.md
Facebook PHP Source Code from August 2007
View README.md
@przor3n
przor3n / Email Server (Linux, Unix, Mac).md
Last active Jan 15, 2020 — forked from raelgc/Email Server (Linux, Unix, Mac).md
Setup a Local Only SMTP Email Server (Linux, Unix, Mac)
View Email Server (Linux, Unix, Mac).md

Setup a Local Only SMTP Email Server (Linux, Unix, Mac)

1 - Point localhost.com to your machine

Most of programs will not accept an email using just @localhost as domain. So, edit /etc/hosts file to make the domain localhost.com point to your machine, including this content to the file:

127.0.0.1 localhost.com

2 - Install Postfix

@przor3n
przor3n / web-servers.md
Created Aug 16, 2019 — forked from willurd/web-servers.md
Big list of http static server one-liners
View web-servers.md

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
View using static variable
function testStatic($dupa){
static $i = 0;
static $last = 100;
echo $last;
return $dupa . " - " . $i++;
}
foreach (range(0,20) as $nn) {
echo testStatic($nn) . "\n";
View generate random string from string
function generate_random($string) {
$charactersLength = strlen($string);
$randomString = '';
for ($i = 0; $i < $charactersLength; $i++) {
$randomString .= $string[rand(0, $charactersLength - 1)];
}
return $randomString;
}
View Drupal 8 - get current node in block
$node = \Drupal::routeMatch()->getParameter('node');
if ($node) {
// You can get nid and anything else you need from the node object.
$nid = $node->id();
}
View wordpress-snips.php
<?php
function removeShit()
{
global $wpdb;
$posts = $wpdb->get_results("
SELECT wp.ID, wp.post_content FROM wp_posts wp, novationstudio_events_event e WHERE wp.post_title = e.title;
");
foreach($posts as $post) {
View gist:5fb8f22524ef65cc3ec6ef3d42e2203e
git checkout develop
git pull
git checkout branch #co by zapisać
git fetch develop
git rebase upstream/develop develop #tutaj sobie cofamy
@przor3n
przor3n / gist:1bab6ff1235849da8693
Created Mar 23, 2016
Git reset local branch to remote
View gist:1bab6ff1235849da8693
git fetch origin
git reset --hard origin/master
View [php] exception using
class InvalidRowException extends \Exception
{
public static function incorrectColumns(Row $row) {
return new static("Row #" . $row->getIndex() . " is missing one or more columns");
}
}
if (!$row->hasColumns($expectedColumns)) {
throw InvalidRowException::incorrectColumns($row);
}