Skip to content

Instantly share code, notes, and snippets.

View newubuntu's full-sized avatar
🏠
Working from home

. newubuntu

🏠
Working from home
View GitHub Profile
@newubuntu
newubuntu / .htaccess
Created August 25, 2024 19:05 — forked from abdelfattahradwan/.htaccess
.htaccess File for SvelteKit Single-Page-Applications
# Rewrite non /app/build/ requests to /app/build/
RewriteCond %{REQUEST_URI} !^/app/build/
RewriteRule ^(.*)$ /app/build/$1 [L]
# Rewrite requests to non-existing files/dirs to /app/build/index.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
@newubuntu
newubuntu / prepare & execute PDO SQL INSERT with placeholders
Created July 28, 2021 02:59 — forked from mllvzeth/prepare & execute PDO SQL INSERT with placeholders
simplified automatic PDO INSERT SQL time saver ⌛ by @Rami_jamleh; with revision by @Clair_Shaw
<?php
/**
* @Rami jamleh - http://php.net/manual/en/pdostatement.execute.php#111823
* @Clair_Shaw(Revision) - http://php.net/manual/en/pdostatement.execute.php#116901
* simplified $placeholder form
**/
$data = ['a'=>'foo','b'=>'bar'];
$keys = array_keys($data);
$fields = '`'.implode('`, `',$keys).'`';
//$placeholder = substr(str_repeat('?,',count($keys),0,-1));
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
await page.goto('https://test-navlang-demo-vvkpjvrhym.now.sh');
await page.setViewport({ width: 1380, height: 900 });
await page.waitFor(1000);
const page2 = await browser.newPage();
@newubuntu
newubuntu / centos7-php7-mssql-driver.md
Created November 5, 2017 05:35 — forked from faizalmansor/centos7-php7-mssql-driver.md
How to Install PHP 7.0 MSSQL Driver on CentOS 7
@newubuntu
newubuntu / WebSockets.md
Created September 16, 2016 11:48 — forked from subudeepak/WebSockets.md
The problems and some security implications of websockets - Cross-site WebSockets Scripting (XSWS)

WebSockets - An Introduction

WebSockets is a modern HTML5 standard which makes communication between client and server a lot more simpler than ever. We are all familiar with the technology of sockets. Sockets have been fundamental to network communication for a long time but usually the communication over the browser has been restricted. The general restrictions

  • The server used to have a permanent listener while the client (aka browser) was not designated any fixed listener for a more long term connection. Hence, every communication was restricted to the client demanding and the server responding.
  • This meant that unless the client requested for a particular resource, the server was unable to push such a resource to the client.
  • This was detrimental since the client is then forced to check with the server at regular intervals. This meant a lot of libraries focused on optimizing asynchronous calls and identifying the response of asynchronous calls. Notably t
@newubuntu
newubuntu / gist:752ef1e0f0448f23db19fb6daa46cb4a
Created September 6, 2016 00:10 — forked from pnommensen/gist:707b5519766ba45366dd
Ghost CMS with NGINX for Maximum Performance

Full blog post can be found here: http://pnommensen.com/2014/09/07/high-performance-ghost-configuration-with-nginx/

Ghost is an open source platform for blogging founded by John O'Nolan and Hannah Wolfe. It's a node.js application and therefore works great in conjunction with nginx. This guide will will help you create a high performance nginx virtual host configuration for Ghost.

"Don't use #nodejs for static content" - @trevnorris. If #nginx isn't sitting in front of your node server, you're probably doing it wrong.

— Bryan Hughes (@nebrius) August 30, 2014
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

The node.js application runs on a port on your server

@newubuntu
newubuntu / clientserver.js
Created September 5, 2016 14:58 — forked from robertklep/clientserver.js
client -> socket.io server 1 (clientserver.js) -> socket.io server 2 (serverserver.js)
var app = require('express')()
, server = require('http').createServer(app)
, io = require('socket.io').listen(server);
server.listen(3012);
app.get('/', function (req, res) {
res.sendfile(__dirname + '/index.html');
});
@newubuntu
newubuntu / linux_running_a_node_service_pm2.md
Created August 15, 2016 00:31 — forked from leommoore/linux_running_a_node_service_pm2.md
Linux - Running a Node Service (PM2)
@newubuntu
newubuntu / jwplayer-rtmp-streaming.html
Created August 11, 2016 12:24 — forked from anunay/jwplayer-rtmp-streaming.html
Javascript: JWPlayer RTMP Streaming Sample Code
<script type='text/javascript'>
jwplayer("PLAYER_ID").setup({
flashplayer: "/jwplayer/player.swf",
controlbar: "bottom",
dock:false,
file: "AUDIO/VIDEO FILENAME",
streamer: "rtmp://STREAMING-DISTRIBUTION-DOMAIN-NAME/cfx/st",
width: "162",
height: "24",
});
@newubuntu
newubuntu / background.js
Created July 25, 2016 17:41 — forked from danharper/background.js
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});