Skip to content

Instantly share code, notes, and snippets.

View brihter's full-sized avatar

Bostjan Rihter brihter

  • Internet
View GitHub Profile
@brihter
brihter / datetime_to_2bytes.cs
Created June 29, 2015 08:27
compresses datetime into 2 bytes
// represent the full date w/ 16 bits (2 bytes)
//
// d - day
// m - month
// y - year
//
/// format:
// d d d d d | m m m m | y y y y y y y
//
// 5 bits to represent the day - 2^5 = 32
@brihter
brihter / MultiCellSelectionModel.js
Last active August 29, 2015 14:07
ExtJS 3.x grid multi-cell selection model
/**
* @class Ext.grid.MultiCellSelectionModel
* @extends Ext.grid.CellSelectionModel
* @cfg {Boolean} enableDrag Enable cell drag
* @cfg {String} dragGroup The name of the drag group, the drag group will only interact with the corresponding drop group
* @cfg {Boolean} enableDrop Enable cell drop
* @cfg {String} dropGroup The name of the drop group, the drop group will only interact with the corresponding drag group
*/
Ext.grid.MultiCellSelectionModel = Ext.extend(Ext.grid.CellSelectionModel, {
constructor: function (config) {
@brihter
brihter / laravel_route_to_controller.php
Created September 17, 2014 11:43
Call Laravel's controller actions automatically, no setup required.
<?php
// app/routes.php
Route::get('/{controller}/{action?}/{params?}', function($controller, $action = 'index', $params = '')
{
// controller
$controller = strtolower($controller);
$controller = ucfirst($controller);
$controller .= 'Controller';
@brihter
brihter / Driver.php
Last active August 29, 2015 14:04
doctrine custom oracle driver implementation that will return native types when executing a raw sql statement
<?php
namespace COMPANY\Core\Vendor\Doctrine\DBAL\Driver\OCI8;
use Doctrine\DBAL\Driver\OCI8\Driver as OCIDriver;
class Driver extends OCIDriver
{
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
@brihter
brihter / vbox_management
Last active August 29, 2015 14:03
resize virtualbox image
# resize
# 25600 = 25 * 1024MB
VBoxManage clonehd "NAME.vmdk" "NAME_CLONE.vdi" --format vdi
VBoxManage modifyhd "NAME_CLONE.vdi" --resize 25600
VBoxManage clonehd "NAME_CLONE.vdi" "NAME1.vmdk" --format vmdk
# download gparted iso and mount it in virtualbox
# extend the partition in gparted, apply changes
# unmount the iso
@brihter
brihter / ext3_object.snippet
Created May 6, 2014 14:20
ExtJS 3.x Visual Studio snippets
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>ext3_object</Title>
<Author>Bostjan Rihter</Author>
<Shortcut>ext3_object</Shortcut>
<Description>ExtJS object snippet</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
@brihter
brihter / opencart_fix_indexes.sql
Last active September 19, 2023 11:26
The script will generate the missing opencart indexes. Copy the result and execute it on the target schema.
use information_schema;
select
concat('alter table `', c.table_name, '` add index `ix_', c.column_name, '` (`',c.column_name,'`);')
from columns c
where c.table_schema = 'SCHEMA_NAME'
and lower(c.column_name) like '%_id%'
and c.column_key = '';
@brihter
brihter / mysql_partitioning.sql
Last active December 21, 2015 08:49
MySQL partitioning snippets (assuming MyISAM engine).
-- create a partitioned table
-- use a default (unused) value for a dummy initial partition when dynamically adding more
create table `TABLE` (
`id` int(10) not null,
...
)
collate='utf8_general_ci'
engine=MyISAM
partition by list (id)
(
@brihter
brihter / oracle_snippets.sql
Last active April 10, 2018 07:22
Oracle snippets
-- create table
create table "TABLE_NAME"
(
"ID" NUMBER(9, 0) NOT NULL,
"COL_1" VARCHAR2(32) NULL,
"COL_2" DATE NULL,
"COL_3" NVARCHAR2(2000) NULL,
"COL_4" NUMBER(9, 0) NOT NULL,
constraint "PK_TABLE_NAME" PRIMARY KEY ("ID")
);
@brihter
brihter / oracle_maintenance.sql
Last active December 20, 2015 20:39
Oracle maintenance snippets
-- backup table
create table TABLE_NAME_BACKUP as select * from TABLE_NAME;
create table user_20130809 as select * from user;
create table role_20130809 as select * from role;
create table function_20130809 as select * from function;
-- disable constraints
-- disable all constraints
begin