Skip to content

Instantly share code, notes, and snippets.

View rnique's full-sized avatar

Roman NL rnique

View GitHub Profile
@rnique
rnique / mp3-jplayer-element.html
Created June 29, 2020 23:55
HTML Snippet, generado por el plugin de Wordpress MP3-jPlayer
<div style="background-color: #222; width: 100%;">
<style type="text/css" scoped="">
#wrapperMI_0 {
padding: 0px !important;
}
</style>
<div style="display: table; margin: 0 auto !important;">
<img src="http://radiocarhuacoto.com/wp-content/themes/wp_muzak5/images/bar.gif">
</div>
@rnique
rnique / fast_invsqrt.cpp
Created June 22, 2017 17:49
Fast Inverse Square Root
// from https://pizer.wordpress.com/2008/10/12/fast-inverse-square-root/
float InvSqrt(float x){
uint32_t i = 0x5F1F1412 - (*(uint32_t*)&x >> 1);
float tmp = *(float*)&i;
return tmp * (1.69000231f - 0.714158168f * x * tmp * tmp);
}
// from http://rrrola.wz.cz/inv_sqrt.html
float inv_sqrt(float x)
{ union { float f; uint32 u; } y = {x};
@rnique
rnique / gist:d3ab65da4ad5add2ee17eb1e3af4a9e4
Last active September 20, 2016 14:29 — forked from maranemil/gist:924f4dcfb59b2ec022b9
Custom AutoIncrement Field in SugarCRM
/**
22/09/2016
1) Copy the file (only if it does not exist) from modules\Accounts\clients\base\views\record\record.php to custom\modules\Accounts\clients\base\views\record\record.php
2) Find your field in this file (for example: [industry])
3) replace
'industry',
by
array( 'name' => 'industry', 'readonly' => true, ),
*/
@rnique
rnique / SugarCRM LAMP Stack Tuning
Created May 5, 2016 22:49 — forked from chicks/SugarCRM LAMP Stack Tuning
SugarCRM Performance Tweaks
Apache:
- Activated 'KeepAlive' connections
- Lowered keep alive timeout from 15 seconds to 2 seconds
- Increased the number of minimum workers from 8 to 16
- Activated server status page (/server-status)
APC (Alternative PHP Cache):
- Set cache size to 256MB (ideal for SugarCRM workload)
Memcache:
@rnique
rnique / Equality test with nulls.sql
Created August 7, 2015 19:24
Tight Equality / Inequality test taking into account possible NULL values (T-SQL).
-- As suggested in Stackoverflow
-- http://stackoverflow.com/questions/1075142/how-to-compare-values-which-may-both-be-null-is-t-sql
--
-- Equality (true if A & B have same value or both are null):
A = B OR ISNULL(A, B) IS NULL
-- OR
ISNULL(NULLIF(A, B), NULLIF(B, A)) IS NULL
-- Inequaltiy (true if A & B are different and contain null):
ISNULL(NULLIF(A, B), NULLIF(B, A)) IS NOT NULL
@rnique
rnique / fnSplitString.sql
Created August 18, 2014 17:55
How to Split a string by delimited char in SQL Server
CREATE FUNCTION [dbo].[fnSplitString]
(
@string NVARCHAR(MAX),
@delimiter CHAR(1)
)
RETURNS @output TABLE(splitdata NVARCHAR(MAX)
)
BEGIN
DECLARE @start INT, @end INT
SELECT @start = 1, @end = CHARINDEX(@delimiter, @string)
@rnique
rnique / custom_utils.php
Last active August 29, 2015 14:04
SugarCRM - function to populate list from Database + static + Wincache
function get_options($lista, $where_sql = '', $order_by_name = false, $paramDB = NULL) {
$mydb = NULL;
static $defaultDB = NULL;
$defaultDB = DBManagerFactory::getInstance();
// Sometimes you may want to use custom connection to another database.
// Then we pass it as the last parameter. Otherwise, we use the default one.
$mydb = ($paramDB?:$defaultDB);
Add a Custom Field to a SugarCRM Module and execute custom PHP code in that field on the DetailView.
Is a 2 step process.
1) Have to modify the detailviewdefs.php file and add a CustomCode to your field in this file...
/custom/modules/<MODULE-NAME_FOLDER>/metadata/detailviewdefs.php
set a variable in a customCode key/value like this...
'customCode' => '{$STATUS}',