Skip to content

Instantly share code, notes, and snippets.

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

Sebastian Ortiz dsebao

🏠
Working from home
View GitHub Profile
@markhowellsmead
markhowellsmead / .htaccess
Last active March 19, 2024 20:25
Detect browser language and redirect to appropriate language version of the website
# Redirect visitors who request the root domain path (e.g. www.mywebsite.ch) to the appropriate language version
# Fallback to English version if no matching browser language defined
# Based on language version being at e.g. www.mywebsite.ch/de/
# This has no effect on any subpaths of the website, and therefore has no effect on e.g. WordPress admin.
# Using a 302 temporary redirect header stops the redirection from being cached in the browser.
# language is ES-MX (Mexico)
RewriteCond %{HTTP:Accept-Language} ^es-mx [NC]
RewriteRule ^$ /mx/ [L,R=302]
@jonathanstark
jonathanstark / verify-google-recaptcha-with-php
Last active March 8, 2024 18:24
Verify Google reCAPTCHA with PHP
#
# Verify captcha
$post_data = http_build_query(
array(
'secret' => CAPTCHA_SECRET,
'response' => $_POST['g-recaptcha-response'],
'remoteip' => $_SERVER['REMOTE_ADDR']
)
);
$opts = array('http' =>
@max-mykhailenko
max-mykhailenko / # Sublime Emmet JSX Reactjs.md
Last active November 25, 2022 23:25
Sublime text 3. Enable Emmet in JSX files with Sublime React plugin

This is no longer needed as Emmet supports JSX - you just need to turn it all on. Did a quick tutorial: http://wesbos.com/emmet-react-jsx-sublime/

Thanks, @wesbos

Problem

  • Using emmet in jsx files
  • Emmet expands text when js autocomplete needed
@akarve
akarve / og-boilerplate.html
Last active November 12, 2023 13:35
Facebook Open Graph tags. Boilerplate for HTML pages.
<!-- Reference: https://developers.facebook.com/docs/sharing/best-practices#tags -->
<!-- CORE og -->
<!-- Title, without branding. -->
<meta property="og:title" content="" />
<!-- Name, not URL (e.g. Apple, not apple.com) -->
<meta property="og:site_name" content="" />
<!-- URL. Should match canonical URL for SEO. Unique identifier for your article. -->
<meta property="og:url" content="" />
<!-- OPTIONAL description. 2-4 sentences. -->
<meta property="og:description" content="" />
@PurpleHippoDesign
PurpleHippoDesign / rss-mailchimp-email
Created November 4, 2014 14:28
Mailchimp RSS Email Template
*|RSSITEMS:|*
<h2 class="mc-toc-title"><a href="*|RSSITEM:URL|*" target="_blank">*|RSSITEM:TITLE|*</a></h2>
<br />
*|RSSITEM:CONTENT_FULL|*<br />
<a href="*|RSSITEM:URL|*" target="_blank">Read in browser &raquo;</a><br />
*|RSSITEM:SHARE:Facebook,Twitter|*&nbsp;*|RSSITEM:PLUSONE|*<br />
*|END:RSSITEMS|*<br />
&nbsp;
<h3 class="h3">Recent Articles:</h3>
*|RSS:RECENT|*
@joshuapinter
joshuapinter / gist:e1774473e5a492e78874
Created November 3, 2014 01:35
Get Airmail cache directory sizes.
cd ~/Library/Containers && du -h -d 0 *airmail*
@Zodiac1978
Zodiac1978 / .htaccess
Last active May 3, 2024 12:11
Safer WordPress with these .htaccess additions
# Don't show errors which contain full path diclosure (FPD)
# Use that line only if PHP is installed as a module and not per CGI
# try using a php.ini in that case.
# Change mod_php5.c to mod_php7.c if you are running PHP7
<IfModule mod_php5.c>
php_flag display_errors Off
</IfModule>
# Don't list directories
<IfModule mod_autoindex.c>
@terrywbrady
terrywbrady / GoogleSpreadsheet.html
Last active May 17, 2024 07:17
Sample HTML/JS to parse a Google Spreadsheet
<!doctype html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
var spData = null;
function doData(json) {
spData = json.feed.entry;
}
@fabiovalse
fabiovalse / README.md
Last active June 16, 2017 14:42
HTML5 DEMO: GEOLOCATION

The following demo intends to describe how to use the HTML5 Geolocation feature. The gist includes three step files:

  • STEP1 index3.html: how to access to the geographical position of a user using the position object;
  • STEP2 index2.html: how to show on a Google Map the geographical position of a user;
  • STEP3 index.html: it is equal to the previous one except for the error handling.
@danferth
danferth / PDO and MySQL.md
Last active April 10, 2023 13:44
Cheat sheet for using PDO (PHP Data Objects) in connecting and querying MySQL database.

PDO (PHP Data Objects)

Cheat sheet for using PDO to interact with MySQL db's

Used to use MySQL then found out it was being depreciated, this is of course right after I got the hang of it and was almost finished with the project i was using to learn myself. So desided to make the switch to PDO way much easier especially if you have security in mind.

For instance instead of $var = mysql_real_escape_string($_POST['data'];, you just $var = $db->quote($_POST['data'];. Or even better use prepared staements and the underlying driver will not only escape but quote the string for you!