Skip to content

Instantly share code, notes, and snippets.

View luchosrock's full-sized avatar
🏃‍♂️
working

Luis Bustamante Flores luchosrock

🏃‍♂️
working
View GitHub Profile
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
break;
}
}
}
var results = Promise.all([1,2,3].map(async (x) => { sleep(5000); await console.log(x); }));
@luchosrock
luchosrock / sensor.ino
Created September 20, 2017 20:04
Connect arduino esp8266 dht11 wemos d1
#include <DHT.h>
#include <ESP8266WiFi.h>
String apiKey = "thingspeak api key";
const char* ssid = "ssid name";
const char* password = "ssid password";
const char* server = "api.thingspeak.com";
#define DHTPIN D2
#define DHTTYPE DHT11
<div id="widget-song">...</div>
<script type="text/javascript">
var datoActual = "";
(function consultarTrack(){
var request = new XMLHttpRequest();
request.open('GET', 'http://softcloudradio.com/trackdata.php', true);
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
// Success!
var data = request.responseText;
@luchosrock
luchosrock / FormatearMonto.sql
Last active March 1, 2016 12:54
Formatear monto decimal a money con 4 decimales con separador de miles (.) y separador de decimales (,)
CREATE FUNCTION FormatearMonto(@NumStr varchar(50))
RETURNS Varchar(50)
AS
BEGIN
declare @OutStr varchar(50)
declare @i int
declare @run int
Select @i=CHARINDEX('.',@NumStr)
if @i=0
@luchosrock
luchosrock / gist:f05bf7d7d87624277696
Created June 10, 2015 15:28
How to enable execution of user defined powershell scripts
#Create file with instructions and save as script.ps1
Write-Host "Hello, World!"
# Open cmder or CMD as Administrator (right button click > Open as administrator)
λ powershell
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. Reservados todos los derechos.
PS> Set-ExecutionPolicy RemoteSigned
#Close program
@luchosrock
luchosrock / vb6palettecolortoRGB.cs
Last active March 1, 2016 12:54
VB6 Palette color to RGB
//lbcolor: color en bd (definido en paleta de vb6 designer)
int lbcolor = 255;
int pBlue = 0;
int pRed = 0;
int pGreen = 0;
if (lbcolor < 256) {
pRed = lbcolor;
pBlue = 0;