Skip to content

Instantly share code, notes, and snippets.

View bbog's full-sized avatar

Bogdan BUCUR bbog

View GitHub Profile
@chrsstrm
chrsstrm / gas_sheet_as_json.js
Last active June 9, 2023 10:38
Treat a Google Sheet like a JSON API
/**
* create a Google Sheet then go to Tools > Script Editor
* Paste this code into the editor. Save.
* Publish > Deploy as Web App
* Set new version, publish as me, who has access - anyone, even anon.
* GET to the URL, add on end ?sheet=[sheet name]
* Sheet name is the sheet name, manage appropriately (no spaces or symbols to keep it simple)
* Request returns JSON representation of the sheet.
*/
@rproenca
rproenca / Clipboard.js
Last active May 2, 2024 10:39
Copy text to clipboard using Javascript. It works on Safari (iOS) and other browsers.
window.Clipboard = (function(window, document, navigator) {
var textArea,
copy;
function isOS() {
return navigator.userAgent.match(/ipad|iphone/i);
}
function createTextArea(text) {
textArea = document.createElement('textArea');
@kmonsoor
kmonsoor / get_yt_video_id.py
Last active February 15, 2024 17:15
Extract Video-ID from a Youtube url
# initial version: http://stackoverflow.com/a/7936523/617185 \
# by Mikhail Kashkin(http://stackoverflow.com/users/85739/mikhail-kashkin)
def get_yt_video_id(url):
"""Returns Video_ID extracting from the given url of Youtube
Examples of URLs:
Valid:
'http://youtu.be/_lOT2p_FCvA',
'www.youtube.com/watch?v=_lOT2p_FCvA&feature=feedu',
@adamwathan
adamwathan / v-cloak.md
Last active February 26, 2023 14:26
Useful CSS utilities for Vue.js cloaking

Handy helpers for controlling visibility of elements until Vue has compiled.

Use like:

<div v-cloak>
  <h1>
    <span class="v-cloak--inline">Loading...</span> <!-- Only displayed before compiling -->
    <span class="v-cloak--hidden">{{ post.title }}</span> <!-- Hidden until compiling is finished -->
 
@bbog
bbog / request.js
Last active April 30, 2020 12:29
XHR Request
var request = function (options) {
// just in case
options = options || {};
var url = options.url,
method = options.method || 'GET',
onSuccess = options.onSuccess,
onError = options.onError,
params = options.params,
@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' =>
@JayHoltslander
JayHoltslander / Multi-column CSS
Last active December 25, 2019 16:58
Split a paragraph into multi columns like a newspaper with this CSS3. Text will automatically fill the columns. You can use this within a single Bootstrap column to simulate multi-column layout without needing to add extra divs for extra columns.
p.4columns {
-webkit-column-count: 4; /* Chrome, Safari, Opera */
-moz-column-count: 4; /* Firefox */
column-count: 4;
-webkit-column-gap: 20px; /* Chrome, Safari, Opera */
-moz-column-gap: 20px; /* Firefox */
column-gap: 20px;
column-rule-color: #ccc; /* Optional */
column-rule-style:solid; /* Optional */
column-rule-width: 1px; /* Optional */
@Stanback
Stanback / nginx.conf
Last active May 3, 2024 12:01 — forked from michiel/cors-nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which
@joshbeckman
joshbeckman / animatedScrollTo.js
Created September 30, 2013 14:51
ScrollTo animation using pure javascript and no jquery
document.getElementsByTagName('button')[0].onclick = function () {
scrollTo(document.body, 0, 1250);
}
function scrollTo(element, to, duration) {
var start = element.scrollTop,
change = to - start,
currentTime = 0,
increment = 20;
@paulhhowells
paulhhowells / memory leaks .js
Last active May 25, 2022 08:33
avoid memory leaks with closures. google javascript style guide.
// from google javascript style guide:
// One thing to keep in mind, however, is that a closure keeps a pointer to its enclosing scope. As a
// result, attaching a closure to a DOM element can create a circular reference and thus, a memory leak.
// For example, in the following code:
// Leaky example
function foo (element, a, b) {
element.onclick = function() {
// uses a and b
// this func keeps a pointer to foo, its enclosing scope