Skip to content

Instantly share code, notes, and snippets.

View farukcam's full-sized avatar
🐢
I may be slow to respond.

Faruk Çam farukcam

🐢
I may be slow to respond.
View GitHub Profile
@farukcam
farukcam / website-monitoring-1
Created August 3, 2022 20:30 — forked from adeekshith/website-monitoring-1
Scripts for website monitoring using Python
#!/usr/bin/env python
# sample usage: checksites.py eriwen.com nixtutor.com yoursite.org
import pickle, os, sys, logging
from httplib import HTTPConnection, socket
from smtplib import SMTP
def email_alert(message, status):
fromaddr = 'you@gmail.com'
@farukcam
farukcam / strip_word_html.php
Last active February 4, 2021 14:04 — forked from dave1010/strip_word_html.php
Strip MS Word HTML. From php.net
<?php
function strip_word_html($text, $allowed_tags = '<b><i><sup><sub><em><strong><u><br><p><div><img>')
{
mb_regex_encoding('UTF-8');
//replace MS special characters first
$search = array('/&lsquo;/u', '/&rsquo;/u', '/&ldquo;/u', '/&rdquo;/u', '/&mdash;/u');
$replace = array('\'', '\'', '"', '"', '-');
$text = preg_replace($search, $replace, $text);
//make sure _all_ html entities are converted to the plain ascii equivalents - it appears
//in some MS headers, some html entities are encoded and some aren't
@farukcam
farukcam / .htaccess
Created November 15, 2020 20:06 — forked from iPublicis/.htaccess
NODE.JS app in Apache - force www. and https: sample .htaccess - partialy based on vielhuber/.htaccess
#########################
#
# NODE.JS app running in Apache
# sample .htaccess - partialy based on vielhuber/.htaccess
# Also rules to enforce www. prefix and https: SSL access
#
# This file must be on the dir where Apache expects to find the website
# The Node App can be anywhere else but must be accessible as explained below.
#
$.getJSON( 'https://graph.facebook.com/?fields=og_object{engagement}&id=' + window.location.href, function( fbdata ) {
console.log(fbdata);
});
@farukcam
farukcam / script.js
Created April 21, 2020 21:02
Show twitter embed in Smart Phone App
!function(d,s,id){
var js,
fjs=d.getElementsByTagName(s)[0],
p='https';
js=d.createElement(s);
js.id=id;
js.src=p+"://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js,fjs);
}
(document,"script","twitter-wjs");
@farukcam
farukcam / validate-tc-id.js
Created July 6, 2019 12:22 — forked from Eomerx/validate-tc-id.js
Validate TC ID
//=======================================
// CHECK TC ID =
//=======================================
var checkTcNum = function(value) {
value = value.toString();
var isEleven = /^[0-9]{11}$/.test(value);
var totalX = 0;
for (var i = 0; i < 10; i++) {
totalX += Number(value.substr(i, 1));
}
@farukcam
farukcam / gist:d594fa37a8c4bde47bc141d203ea8f7c
Created July 6, 2019 12:20 — forked from ziyahan/gist:3938729
Vergi Kimlik No Doğrulama Algoritması
function vergikimlik(kno) {
var v1 = 0;
var v2 = 0;
var v3 = 0;
var v4 = 0;
var v5 = 0;
var v6 = 0;
var v7 = 0;
var v8 = 0;
var v9 = 0;
@farukcam
farukcam / php-html-css-js-minifier.php
Created February 16, 2019 09:02 — forked from Rodrigo54/php-html-css-js-minifier.php
PHP Function to Minify HTML, CSS and JavaScript
<?php
/**
* -----------------------------------------------------------------------------------------
* Based on `https://github.com/mecha-cms/mecha-cms/blob/master/system/kernel/converter.php`
* -----------------------------------------------------------------------------------------
*/
// HTML Minifier
function minify_html($input) {
@farukcam
farukcam / logger.js
Created October 3, 2018 12:32 — forked from sht5/logger.js
winston-logzio integration with winston in nodejs
/**
* Created by shahartaite on 12/09/2016.
*/
const winston = require('winston');
const logzioWinstonTransport = require('winston-logzio');
const loggerOptions = {
token: 'YOUR_TOKEN',
host: 'listener.logz.io',
type: 'nodejs' // if you integrate any other services with logz.io such
// as your clientside logs you can differentiate using this property
@farukcam
farukcam / Props
Created September 13, 2018 12:44 — forked from mynameispj/Props
Estimated reading time in PHP, by Brian Cray
Total props to Brian Cray: http://briancray.com/posts/estimated-reading-time-web-design/