Skip to content

Instantly share code, notes, and snippets.

View Avaray's full-sized avatar
🙂
Looking for work

Avaray Avaray

🙂
Looking for work
View GitHub Profile
clear; con_logfile cvarlist.txt; cvarlist; con_logfile end
@Avaray
Avaray / app.js
Created November 15, 2019 12:18
[NodeJS] HTTP Request without dependencies // https://www.tomas-dvorak.cz/posts/nodejs-request-without-dependencies/
const request = function(url) {
return new Promise((resolve, reject) => {
const lib = url.startsWith('https') ? require('https') : require('http');
const request = lib.get(url, (response) => {
if (response.statusCode < 200 || response.statusCode > 299) {
reject(new Error('Failed to load page, status code: ' + response.statusCode));
}
const body = [];
response.on('data', (chunk) => body.push(chunk));
response.on('end', () => resolve(body.join('')));
@Avaray
Avaray / app.js
Last active February 24, 2019 14:15
[NodeJS] Puppeteer Starter // for API visit https://pptr.dev/
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({headless: true})
var pages = await browser.pages()
var page = pages[0]
await page.goto('')
@Avaray
Avaray / gist:8a6b8e2cf872edf49a1d5e2317d0ddde
Last active February 7, 2019 21:13
List of blogs with rating 100/100 in Google PageSpeed Insights.
// REAL BLOGS, ENTIRELY OPTIMISED
https://blog.fefe.de/
http://prog21.dadgum.com/
https://zupzup.org/
https://elliotec.com
https://www.tedunangst.com/flak/
http://rtfm.killfile.pl/
// OTHER BLOGS OR MOTIVATIONS YOU CAN CHECK
@Avaray
Avaray / app.js
Created January 10, 2019 22:33
[NodeJS] Create HTTP server in simple way
require('http')
.createServer()
.listen({
port: 4000
})
.on('request', (req, res) => {
res.end('Hello World!');
});
@Avaray
Avaray / app.js
Last active May 11, 2018 00:18
[JS] Delete empty Keys from Object
function clean(o) {
Object.keys(o).forEach(k => (!o[k] && o[k] !== undefined) && delete o[k]);
return o;
}
@Avaray
Avaray / app.js
Created May 11, 2018 00:18
[JS] Sort Keys in Object alphabetically
let a = {};
Object.keys(b).sort().forEach(key => {
a[key] = b[key];
});
@Avaray
Avaray / _level_sounds.txt
Last active March 19, 2018 18:33
_level_sounds.txt
@echo off
:: ouput the embeded text file to a temporary file
for /f "delims=:" %%N in ('findstr /nxl /c:"::BEGIN TEXT" "%~f0"') do (
more +%%N "%~f0" >default_level_sounds.txt
)
:: loop through jump map files, and copy the embeded text file to <filename>_level_sounds.txt
for /f %%f in ('dir /b .\jump_*.bsp') do (
copy "default_level_sounds.txt" "%%~nf_level_sounds.txt" >nul 2>&1 && echo %%~nf
@Avaray
Avaray / style.pug
Created November 2, 2017 01:56
Pug // Condition in CSS in .pug partial file // https://stackoverflow.com/a/41618071/4415165
style
.
.someclass1{
font-size:10px;
}
.someclass2{
font-size:10px;
}
if options.key1=='a'
.
@Avaray
Avaray / app.js
Last active November 1, 2017 15:37
Node JS // Get list of all directories (not recursive)
var fs = require('fs')
var path = require('path')
var location = 'content'
fs.readdirSync(location)
.filter(x => {
return fs.lstatSync(path.join(location, x)).isDirectory()
})
.forEach(dir => {