Skip to content

Instantly share code, notes, and snippets.

Matias matiasa18

Block or report user

Report or block matiasa18

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View solution.rb
require "minitest/autorun"
# Solution for
# 1.Given an array of n integers where _n > 1_, `nums`, return an array `output` such that `output[i]`
# is equal to the product of all the elements of nums except `nums[i]`.
#
# Solve it **without division** and leave a comment with the time complexity of your algorithm.
#
# For example, given `[1,2,3,4]`, return `[24,12,8,6]`.
def problem_1 (nums)
View gist:8152730
var fs = require('fs'),
required_files = [];
module.exports = function(app) {
recursive_require(__dirname, __dirname, app);
function recursive_require(directory, base_dir, app) {
fs.readdirSync(directory).forEach(function (input) {
var next_directory = directory + '\\' + input + '\\';
View gist:8008133
var passport = require('passport'),
Category = require('../../../models/category'),
messages = require('../../../modules/messages');
module.exports = function(app) {
app.get('/admin/categories/add', function(req, res) {
Category.find(function(err, categories) {
if (err) throw err;
res.render('admin/categories/form', {title: 'Add Category', category: new Category(), path: '/admin/categories/add', categories: categories, edit: false});
View gist:8007867
var mongoose = require('mongoose'),
auto_increment = require('mongoose-auto-increment');
var category_schema = new mongoose.Schema({
name: {required: true, type: String},
categories: [{ name: {required: true, type: String}}],
parent_id: Number
});
category_schema.plugin(auto_increment.plugin, 'Category');
@matiasa18
matiasa18 / gist:7916775
Last active Dec 31, 2015
Preload all controllers.
View gist:7916775
var fs = require('fs'),
required_files = [];
module.exports = function(app) {
recursive_require(__dirname, __dirname, app);
function recursive_require(directory, base_dir, app) {
fs.readdirSync(directory).forEach(function (input) {
var next_directory = directory + '/' + input + '/';
View dbhandler.php
<?php
class Dbh {
private $db;
private $querys = array();
private $result;
private $log;
public function __construct( $db ) {
View index.php
<?php
$count = 0;
$string = '-----hello--';
for ($i=0; $i<strlen($string); $i++) {
if ($string[$i] == '-') {
$count ++;
}
}
You can’t perform that action at this time.