Skip to content

Instantly share code, notes, and snippets.

View danielnaranjo's full-sized avatar

Daniel Naranjo danielnaranjo

View GitHub Profile
@danielnaranjo
danielnaranjo / data.service.ts
Last active September 10, 2018 19:15
HTTP calls using a reusable function (TS, Angular 5/6)
import { Component, Injectable } from '@angular/core';
import * as urljoin from 'url-join';
import { environment } from '../environments/environment';
import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http';
import { Router } from '@angular/router';
@Injectable()
export class DataProvider {
apiUrl: string;
@danielnaranjo
danielnaranjo / btc-eth-dca-buy.php
Created August 27, 2018 20:38 — forked from levelsio/btc-eth-dca-buy.php
This script runs daily and "Dollar Cost Average"-buys $40 BTC and $10 ETH per day
<?
//
// [ BUY BTC & ETH DAILY ON BITSTAMP ]
// by @levelsio
//
// 2017-08-23
//
// 1) buy $40/day BTC
// 2) buy $10/day ETH
//
<?php namespace App\Providers;
use Illuminate\Support\ServiceProvider;
/**
* If the incoming request is an OPTIONS request
* we will register a handler for the requested route
*/
class CatchAllOptionsRequestsProvider extends ServiceProvider {
// Remove HTML tags from data response
// Example: <p>Hello <strong>World</strong>!</p>
// Return: Hello World!
var cleanTags = function(input) {
return input.replace(/<.+?>/g, '');
}
cleanTags('<p>Hello <strong>World</strong>!</p>');
@danielnaranjo
danielnaranjo / reformat_simple_date.js
Last active February 5, 2018 13:28
Reformat Simple date.
// As you know how's date is coming
// You do not need to validate or do something else..
// Example: 2018-02-05 12:00 but you date to be displayed need to be: dd/mm/yyyy
// Display into HTML tag like <div id="demo"></div>
// document.getElementById("demo").innerHTML = reformat('2018-02-05 12:00');
var reformat = function(input){
var original = input.split(" "); // Split: This one: 2018-02-05 and this one: 12:00
var changed = original[0].split("-") // Now, split it again to: DD/MM/YYYY
return changed[2]+'/'+changed[1]+'/'+changed[0]; // Returned!
@danielnaranjo
danielnaranjo / send_remote_syslog.php
Created July 13, 2017 14:24 — forked from troy/send_remote_syslog.php
Send UDP remote syslog message from PHP (RFC 3164)
# replace PAPERTRAIL_HOSTNAME and PAPERTRAIL_PORT
# see http://help.papertrailapp.com/ for additional PHP syslog options
function send_remote_syslog($message, $component = "web", $program = "next_big_thing") {
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
foreach(explode("\n", $message) as $line) {
$syslog_message = "<22>" . date('M d H:i:s ') . $program . ' ' . $component . ': ' . $line;
socket_sendto($sock, $syslog_message, strlen($syslog_message), 0, PAPERTRAIL_HOSTNAME, PAPERTRAIL_PORT);
}
socket_close($sock);
@danielnaranjo
danielnaranjo / dnsbl.sh
Created December 28, 2016 14:09 — forked from agarzon/dnsbl.sh
DNS Black List - Linux shell script (improved from: http://www.daemonforums.org/showthread.php?t=302)
#!/bin/sh
# Check if an IP address is listed on one of the following blacklists
# The format is chosen to make it easy to add or delete
# The shell will strip multiple whitespace
BLISTS="
bl.score.senderscore.com
bl.mailspike.net
bl.spameatingmonkey.net
b.barracudacentral.org
@danielnaranjo
danielnaranjo / .htaccess
Created September 13, 2016 14:17 — forked from ludo237/.htaccess
The ultimate .htaccess file. Please feel free to fork it, edit it and let me know what do you think about it.
# Apache configuration file
# httpd.apache.org/docs/2.2/mod/quickreference.html
# Note .htaccess files are an overhead, this logic should be in your Apache
# config if possible: httpd.apache.org/docs/2.2/howto/htaccess.html
# Techniques in here adapted from all over, including:
# Kroc Camen: camendesign.com/.htaccess
# perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/
# Sample .htaccess file of CMS MODx: modxcms.com
# This is the free sample of .htaccess from 6GO s.r.l.
# @author Claudio Ludovico Panetta (@Ludo237)

#How you get Sail.js running on Openshift#

This instruction is tested with:

  • Sails.js v0.9.16
  • Node.js 0.10 on Openshift ( 05 May 2014)

###1) package.json

If you use the package.json build by sails new Projectname than you have to add a few fields for openshift – so the server can start you app automatically. Sails uses Grunt to build minify css/js and so on. Openshift dont have grunt installed so you have to add this also.

<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Stripe Getting Started Form</title>
<!-- The required Stripe lib -->
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<!-- jQuery is used only for this example; it isn't required to use Stripe -->