Skip to content

Instantly share code, notes, and snippets.

View domainoverflow's full-sized avatar

DomainOverflow.com domainoverflow

View GitHub Profile
@domainoverflow
domainoverflow / MongoDbCursorToPhpArrayAtALowerCost.php
Last active July 26, 2018 13:31
Convert MongoDB cursor to PHP Array at a lower cost. Instead of using cursor.toArray() (at the time of the query ) which can be heavy, the function below allows you to convert MongoDB\Cursor directly into a PHP Array locally, improving the overall performance of the Iteration between PHP and MongoDB.
public function convertMongoDBCursorToArray($dbcursor) {
$counter=0; $x=0;
$finalarray = Array() ; $convertedarray=Array() ;
foreach($dbcursor as $document) { $finalarray[$counter]=$document; $counter++;}
$finalarray=array_values($finalarray);
$thissize = count($finalarray);
$counter=0;
@jesugmz
jesugmz / 60-jetbrains.conf
Last active April 24, 2023 17:32
Avoid the message 'External file changes sync may be slow: The current inotify(7) watch limit is too low.' from JetBrains products
#
# Avoid the message 'External file changes sync may be slow: The current inotify(7) watch limit is too low.' from JetBrains products.
#
# 1. Create the file /etc/sysctl.d/60-jetbrains.conf and paste this code
# 2. Restart the sysctl service: sudo sysctl -p --system
# 3. Restart the IDE
#
# More info:
# https://confluence.jetbrains.com/display/IDEADEV/Inotify+Watches+Limit
# Remove foreman
yum remove remove foreman foreman-installer foreman-proxy
rm -rf /var/lib/foreman /usr/share/foreman /usr/share/foreman-proxy/logs
rm /etc/httpd/conf.d/foreman.conf
# Remove puppet
yum remove puppet puppetmaster puppet-common puppetmaster-common puppetlabs-release
rm -rf /usr/lib/ruby/vendor_ruby/puppet /usr/share/puppet /var/lib/puppet /etc/puppet
rm /etc/apache2/conf.d/puppet.conf
@bubba-h57
bubba-h57 / closeConnection.php
Created January 14, 2015 21:39
Easy way to close connections to the browser and continue processing on the server.
<?php
/**
* Close the connection to the browser but continue processing the operation
* @param $body
*/
public function closeConnection($body, $responseCode){
// Cause we are clever and don't want the rest of the script to be bound by a timeout.
// Set to zero so no time limit is imposed from here on out.
set_time_limit(0);
@tmpvar
tmpvar / my-first-module.md
Last active December 20, 2021 18:48
how to create your very first node.js module and publish it to the npm registry

building your first node module

This is pretty simple, lets dive in!

choose a name

Find a name that isn't taken and clearly describes what your module is doing

$ npm view your-first-node-module
@jdevalk
jdevalk / .htaccess
Last active November 28, 2023 20:28
These three files together form an affiliate link redirect script.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteRule (.*) ./index.php?id=$1 [L]
</IfModule>
@ografael
ografael / combo_dinamico.html
Created March 14, 2012 15:12
Carregar combo com JQuery - Cidades e Estados
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$.getJSON('estados_cidades.json', function (data) {