Skip to content

Instantly share code, notes, and snippets.

View vyspiansky's full-sized avatar

Ihor Vyspiansky vyspiansky

View GitHub Profile
@nathansmith
nathansmith / module_pattern_init.js
Created January 11, 2010 17:08
Init + Module Pattern JS
// JS Module Pattern:
// http://j.mp/module-pattern
// Redefine: $, window, document, undefined.
var APP = (function($, window, document, undefined) {
// Automatically calls all functions in APP.init
$(document).ready(function() {
APP.go();
});
@ocean90
ocean90 / box-shadow.html
Last active April 11, 2024 13:54
CSS3 Box Shadow, only top/right/bottom/left and all
<!DOCTYPE html>
<html>
<head>
<title>Box Shadow</title>
<style>
.box {
height: 150px;
width: 300px;
margin: 20px;
@kevinSuttle
kevinSuttle / meta-tags.md
Last active May 12, 2024 15:28 — forked from lancejpollard/meta-tags.md
List of Usable HTML Meta and Link Tags
@troy
troy / send_remote_syslog.php
Last active April 6, 2023 18:19
Send UDP remote syslog message from PHP (RFC 3164)
# replace PAPERTRAIL_HOSTNAME and PAPERTRAIL_PORT
# see http://help.papertrailapp.com/ for additional PHP syslog options
function send_remote_syslog($message, $component = "web", $program = "next_big_thing") {
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
foreach(explode("\n", $message) as $line) {
$syslog_message = "<22>" . date('M d H:i:s ') . $program . ' ' . $component . ': ' . $line;
socket_sendto($sock, $syslog_message, strlen($syslog_message), 0, PAPERTRAIL_HOSTNAME, PAPERTRAIL_PORT);
}
socket_close($sock);
@andersonaguiar
andersonaguiar / how-to-install-sass-on-windows
Created April 16, 2012 18:03
How to install SASS on Windows 7
How to install SASS on Windows 7
1 - Download the ruby http://rubyinstaller.org/downloads/
2 - Click install and select the option to create environment variables
(
If you forgot to schedule go to:
My Computer> Properties> Advanced Options> Environment Variables
Look for path and put in the path of the ruby bin installed, eg: C:\Ruby193\bin;
)
3 - Open cmd and download the gem of the SASS, typing: gem install sass
@rodneyrehm
rodneyrehm / parseAttributes.php
Created July 8, 2012 09:20
PHP: parse HTML element attributes
<?php
function parseAttributes($text) {
$attributes = array();
$pattern = '#(?(DEFINE)
(?<name>[a-zA-Z][a-zA-Z0-9-:]*)
(?<value_double>"[^"]+")
(?<value_single>\'[^\']+\')
(?<value_none>[^\s>]+)
(?<value>((?&value_double)|(?&value_single)|(?&value_none)))
@DonDebonair
DonDebonair / export-comments-for-disqus-xml.php
Last active July 30, 2019 08:10
Convert Comments in a MySQL database (in this case from the Diem CMS) to a Wordpress WXR file that can be imported by Disqus
<?php
/*
Convert Comments in a MySQL database (in this case from the Diem CMS) to a Wordpress WXR file that can be imported by Disqus
usage: $ php export-comments-for-disqus-xml.php > comments.xml
*/
$connection = mysql_connect('localhost', 'username', 'password') or die(mysql_error());
$db = mysql_SELECT_db('databasename', $connection);
db_query("set character_set_client='utf8'");
db_query("set character_set_results='utf8'");
package ca.uwo.csd.cs2212.USERNAME;
public class BankAccount {
private double balance;
public BankAccount(double balance) {
this.balance = balance;
}
@neo22s
neo22s / validate.php
Last active October 18, 2020 02:25
validate domain name in PHP
<?
/**
* checks if a domain name is valid
* @param string $domain_name
* @return bool
*/
public static function domain_name($domain_name)
{
//FILTER_VALIDATE_URL checks length but..why not? so we dont move forward with more expensive operations
$domain_len = strlen($domain_name);

What's the difference between cascade="remove" and orphanRemoval=true in Doctrine 2

TLDR: The cascade={"remove"} is like a "software" onDelete="CASCADE", and will remove objects from the database only when an explicit call to $em->remove() occurs. Thus, it could result in more than one object being deleted. orphanRemoval can remove objects from the database even if there was no explicit call to ->remove().

I answered this question a few times to different people so I will try to sum things up in this Gist.

Let's take two entities A and B as an example. I will use a OneToOne relationship in this example but it works exactly the same with OneToMany relationships.

class A