Skip to content

Instantly share code, notes, and snippets.

@dennisdegryse
dennisdegryse / gist:4953694
Created February 14, 2013 15:52
Proof of concept for object serialization. Note: custom data objects must override the equals method and implement
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.io.Serializable;
public class TestApp {
public static class DataPackage implements Serializable {
@dennisdegryse
dennisdegryse / gist:7452258
Created November 13, 2013 16:46
Distributed Sysems - JEE: getAvailableCarTypes
// Distributed Systems - JEE/CarRental-ejb/src/java/session/CarRentalSession.java:
@Override
public List<CarType> getAvailableCarTypes(Date start, Date end) {
final Query query = em.createNamedQuery("CarRentalCompany.findAll", CarRentalCompany.class);
final List<CarType> availableCarTypes = new LinkedList<CarType>();
final List<CarRentalCompany> companies = query.getResultList();
for (final CarRentalCompany rentalCompany : companies)
for(final CarType type : rentalCompany.getAvailableCarTypes(start, end))
if(!availableCarTypes.contains(type))
uint8 input[] = { 'd' };
uint8 digest[20];
sha1_context *ctx = malloc(sizeof(struct sha1_context));
sha1_starts (ctx);
sha1_update (ctx, input, 2);
sha1_finish (ctx, digest);
<?php
require_once("ajax_table.class.php");
// [dennis] rename your object from ajax_table to AjaxTable (conventions)
// [dennis] rename your object to AjaxRepository (semantics)
$obj = new ajax_table();
// [dennis] use the $_SERVER variable to determine the request method.
if($_SERVER['REQUEST_METHOD'] == 'POST') {
// whats the action ??
@dennisdegryse
dennisdegryse / gist:17246e604947e52e44de
Created December 5, 2014 15:51
ajax_table.class.php
<?php
// [dennis] read suggestions on your class name in the ajax.php comments
class ajax_table {
public function __construct(){
$this->dbconnect();
}
private function dbconnect() {
$conn = mysqli_connect("localhost","root","","ajax_table")
@dennisdegryse
dennisdegryse / Router.php
Created December 5, 2014 16:30
Basic URI router concept
<?php
class Router {
private $_defaultParameters;
public Router($defaultParameters) {
$this->_defaultParameters = $defaultParameters;
}
public function route($uri) {
@dennisdegryse
dennisdegryse / ajaxsubmit.php
Last active August 29, 2015 14:10
AJAX Problem (Sushma Reddy)
<?php
// Establishing Connection with Server..
$connection = mysqli_connect("localhost", "root", "")
or die("Could not connect to database at 'localhost'");
// Selecting Database
mysql_select_db($connection, "ajax")
or die("Could not open database 'ajax'");
?>
@dennisdegryse
dennisdegryse / gist:4b0505a12eeb12f35bbf
Last active August 29, 2015 14:11
HTML Table rowspan problem
<table class="table tab-content" style="width:95%" align="center">
<tr class="row">
<td style="width:100px; height=100%;" rowspan="2">
<img width="100%" src="adimg/autos/11.jpg"/>
</td>
<td colspan="2">
<h4 class="h4">This is a new Car please call</h4>
</td>
</tr>
<tr class="row" >
<?php
/**
* This package can be used to display query results split in pages using PDO
*
* It is based on my primary classe available on
* http://www.phpclasses.org/browse/file/40496.html
* and since the most usage is been from countries outside Brazil
* I've ported the class methods and properties names to English
*
@dennisdegryse
dennisdegryse / gist:85c9281130dbb2148fcc
Last active August 29, 2015 14:11
Basic PHP template example
<?php
// some templates
$link = '<a href="%uri%">%text%</a>';
$strong = '<strong>%text%</strong>';
// some data
$linkUri = "http://example.com";
$linkText = "example";
$strongText = "foobar";