Skip to content

Instantly share code, notes, and snippets.

View Talento90's full-sized avatar

Marco Talento Talento90

View GitHub Profile
@mwender
mwender / visual-composer-html-id-option.php
Last active November 23, 2017 07:11
Add an HTML ID option to Visual Composer rows in the X Theme
<?php
function x_child_visual_composer_update_existing_shortcodes(){
if ( function_exists( 'vc_add_param' ) ) {
vc_add_param( 'vc_row', array(
'type' => 'textfield',
'heading' => "HTML ID",
'param_name' => 'element_id',
'value' => '',
'description' => __( "Assign an ID to the row", "discprofile" ),
) );
@manjuraj
manjuraj / scalaz-disjunction.scala
Last active November 12, 2018 16:15
scalaz disjunction
//
// Disjunction - aka Scalaz Either
// \/[A, B] is an alternative to Either[A, B]
// -\/ is Left (usually represents failure by convention)
// \/- is Right (usually represents success by convention)
// Left or Right - which side of the Disjunction does the "-" appear?
//
// Prefer infix notation to express Disjunction Type v: String \/ Double
//
// References
@BinaryMuse
BinaryMuse / restful.js
Last active March 17, 2019 08:22
Express API with Async/Await
import express from "express";
/**
* Takes a route handling function and returns a function
* that wraps it after first checking that the strings in
* `reserved` are not part of `req.body`. Used for ensuring
* create and update requests do not overwrite server-generated
* values.
*/
function checkReservedParams(routeHandler, ...reserved) {
@wallymathieu
wallymathieu / Startup.cs
Last active March 28, 2019 13:21
HowTo register auth for swashbuckle with identity server on asp.net core
Namespace ProjectWithSwagger
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container
public void ConfigureServices(IServiceCollection services)
{
//....
services.ConfigureSwaggerGen(swaggerGen =>
{
@james-world
james-world / FSharpTalk.md
Last active December 6, 2019 17:04
Notes from a talk on FSharp
@razie
razie / scalaskilset.markdown
Created December 9, 2010 17:42
Scala skill levels
@Hendrixer
Hendrixer / Gulpfile.js
Last active June 7, 2022 14:42
Gulpfile with Livereload, Nodemon, and other features
var gulp = require('gulp'),
concat = require('gulp-concat'),
plumber = require('gulp-plumber'),
server = require('tiny-lr')(),
refresh = require('gulp-livereload'),
mocha = require('gulp-mocha'),
stylus = require('gulp-stylus'),
notify = require('gulp-notify'),
nodemon = require('gulp-nodemon'),
jshint = require('gulp-jshint'),
@yetanotherchris
yetanotherchris / google-cloud-pubsub-example.cs
Last active December 16, 2022 13:56
Google Cloud Pub/Sub C# example
//
// Google Cloud Pub/Sub C# example
// NOTE: This is a .NET Core 1.1 console app.
// Use "dotnet run" to run it, run setup.ps1 first.
//
using System;
using System.Collections.Generic;
using Google.Cloud.PubSub.V1;
using Google.Protobuf;
@almeidap
almeidap / BaseDAO.scala
Last active March 25, 2023 12:26
DAO design for ReactiveMongo using JSONCollection and Play2 Scala JSON API (work in progress).
package core.dao
import scala.concurrent.Future
import play.api.Logger
import reactivemongo.core.commands.LastError
import reactivemongo.core.errors.DatabaseException
import core.db.MongoHelper
@cerebrl
cerebrl / 1-securing-express.md
Last active August 2, 2023 22:48
Securing ExpressJS

tl;dr

  1. Don't run as root.
  2. For sessions, set httpOnly (and secure to true if running over SSL) when setting cookies.
  3. Use the Helmet for secure headers: https://github.com/evilpacket/helmet
  4. Enable csrf for preventing Cross-Site Request Forgery: http://expressjs.com/api.html#csrf
  5. Don't use the deprecated bodyParser() and only use multipart explicitly. To avoid multiparts vulnerability to 'temp file' bloat, use the defer property and pipe() the multipart upload stream to the intended destination.