Skip to content

Instantly share code, notes, and snippets.

View cristianciofu's full-sized avatar

Cristian CIOFU cristianciofu

  • Strasbourg, France
View GitHub Profile
@cristianciofu
cristianciofu / .gitconfig
Created June 17, 2013 09:19
.gitconfig - proxy settings
[http]
proxy = http://PROXY_ADDRESS:PROXY_PORT
@cristianciofu
cristianciofu / twig_function_from_php.php
Created June 18, 2013 08:57
Add (and use) a custom php function in your twig template
<?php
// let's say we added in our project the "eatCandy" method
// that displays something onsilly the screen
// and now we want to call this method in our template
// NOTE : eatCandyNow will be the name of the twig function we'll create
$function = new Twig_SimpleFunction('eatCandyNow', function () {
return eatCandy(); // our php function
});
$twig->addFunction($function);
@cristianciofu
cristianciofu / jTableColumnEditorFix.css
Created June 19, 2013 13:46
Display the jTable add / edit form on multiple columns
#jtable-create-form, #jtable-edit-form {
display: block;
width: 550px;
-moz-column-gap:40px;
-webkit-column-gap:40px;
column-gap:40px;
-moz-column-count:2;
-webkit-column-count:2;
column-count:2;
}
@cristianciofu
cristianciofu / phpDateTimeMondayFirstDay.php
Created June 22, 2013 10:48
Change php's DateTime behavior to use Monday as first day of the week
<?php
// found it here :
// http://stackoverflow.com/questions/13128854/php-datetime-class-change-first-day-of-the-week-to-monday
class EuroDateTime extends DateTime {
// Override "modify()"
public function modify($string) {
@cristianciofu
cristianciofu / jTableCascade.js
Last active December 19, 2015 02:29
jTable Dropdowns in Cascade
<script>
// ...
id_famille: {
title: 'Family',
list: true,
create: true,
edit: true,
options: { '1': 'Fam_1', '2': 'Fam_2', '3': 'Fam_3' }
},
id_liste: {
@cristianciofu
cristianciofu / reset_auto_increment.sql
Created July 1, 2013 12:55
Reset AUTO_INCREMENT value in MySQL
ALTER TABLE tablename AUTO_INCREMENT = 1
@cristianciofu
cristianciofu / searchConstraint
Created July 19, 2013 08:55
Find where a primary key is used as a foreign key
USE information_schema;
SELECT * FROM KEY_COLUMN_USAGE
WHERE
REFERENCED_TABLE_NAME = 'YOUR_TABLE_NAME'
AND
REFERENCED_COLUMN_NAME = 'YOUR_FIELD';
@cristianciofu
cristianciofu / twoDBFieldUpdater.sql
Created July 19, 2013 13:41
In case you'll ever need to update a field from a table with a value that's on a different table
UPDATE TABLE1
INNER JOIN TABLE2 ON (TABLE1.field = TABLE2.field)
SET TABLE1.fieldToChange = TABLE2.fieldNewValue
@cristianciofu
cristianciofu / PDO_charset.php
Created August 8, 2013 08:08
PHP PDO: charset - excellent if working with french characters
<?php
$connect = new PDO(
"mysql:host=$host;dbname=$db",
$user,
$pass,
array(
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"
)
);
@cristianciofu
cristianciofu / test892652.js
Created September 17, 2013 13:09
enable / disable dropdown
$(document).ready(function() {
$("#chkdwn2").click(function() {
if ($(this).is(":checked")) {
$("#dropdown").prop("disabled", true);
} else {
$("#dropdown").prop("disabled", false);
}
});
});