Skip to content

Instantly share code, notes, and snippets.

View georgioupanayiotis's full-sized avatar
🛰️

Panayiotis Georgiou georgioupanayiotis

🛰️
View GitHub Profile
@georgioupanayiotis
georgioupanayiotis / base64-encoded-Authorization.js
Created January 16, 2023 21:46
Generating base64-encoded Authorization Node.js
var username = 'Test';
var password = '123';
var auth = 'Basic ' + new Buffer(username + ':' + password).toString('base64');
var header = {'Host': 'www.example.com', 'Authorization': auth};
var request = client.request('GET', '/', header);
<div id="membercounterwrapper"> <span>EDITION #</span>
<a href="#"><span class="odom">0</span></a>
</div>
@georgioupanayiotis
georgioupanayiotis / zendesk-tickets.js
Created October 31, 2017 15:42
Create multiple zendesk tickets
for(x=0; x<500; x++) {
var title = "Ticket #" + x;
var subject = "Test ticket #" + x;
var body = "This is test ticket #" + x;
$.ajax({
url: '/api/v2/tickets.json',
contentType:'application/json',
type: 'POST',
data: JSON.stringify({"ticket": {"subject": subject , "comment": { "body": body }}})
});
@georgioupanayiotis
georgioupanayiotis / complex-example.js
Created March 15, 2017 10:44
Complex object validatio
var objectSchema = Joi.object().keys({
username: Joi.string().alphanum().min(3).max(50).required(),
email: Joi.string().email().required()
});
@georgioupanayiotis
georgioupanayiotis / simple-example.js
Created March 15, 2017 10:41
Example - Simple Joi Schema
var stringSchema = Joi.string().min(3).max(30);
Joi.validate(‘valid string’, stringSchema,
function(error,val) {
//do stuff
});
@georgioupanayiotis
georgioupanayiotis / main.js
Created February 8, 2017 12:01
Node.js - Intro Hello World example
var http = require("http");
http.createServer(function (request, response) {
// Send the HTTP header
// HTTP Status: 200 : OK
// Content Type: text/plain
response.writeHead(200, {'Content-Type': 'text/plain'});
// Send the response body as "Hello World"
@georgioupanayiotis
georgioupanayiotis / config
Created June 28, 2015 17:59
Symfony2: app_dev.php allow access only to IP address
$whitelistIPs = array('127.0.0.1', 'fe80::1', '::1', 'my.organisation.ip.address');
//allow app_dev.php only under these conditions (prevent for production environment) uses HTTP_X_FORWARDED_FOR because behind load balancer
if (
isset($_SERVER['HTTP_X_FORWARDED_FOR']) &&
( ! in_array(@$_SERVER['HTTP_X_FORWARDED_FOR'], $whitelistIPs) )
){
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access the development environment.');
}
@georgioupanayiotis
georgioupanayiotis / custom.php
Created June 19, 2015 09:13
How to Include WordPress Custom Post Types to Your Site RSS Feed
<?php
function add_to_custom_feed($qv) {
if (isset($qv['feed']) && !isset($qv['post_type']))
$qv['post_type'] = array('post', 'books', 'events');
return $qv;
}
add_filter('request', 'add_to_custom_feed');
?>
@georgioupanayiotis
georgioupanayiotis / submit.css
Created June 4, 2015 15:05
Enable custom submit button styling in Safari mobile
/*
*In order to remove native style is possible to set “appearance” to none,
*thus to enable complete custom styling of our submit buttons we can write the following CSS statement:
*Some notes:
*vendors-specific declarations (-webkit, -moz) may be removed
*do not reset appearance for all the HTML elements (ie: “*”) or you will have to work hard to restyling complex components like select!
*/
input[type='submit']
{
-webkit-appearance: none;
@georgioupanayiotis
georgioupanayiotis / search-form.php
Created June 4, 2015 13:22
Input field and submit button on the same line, full width.
<form action="search.php" method="get">
<input type="submit" name="search" value="Go" style="float: right" />
<div style="overflow: hidden; padding-right: .5em;">
<input type="text" name="term" style="width: 100%;" />
</div>
</form>