Skip to content

Instantly share code, notes, and snippets.

@mandiwise
mandiwise / Update remote repo
Last active April 17, 2024 07:41
Transfer repo from Bitbucket to Github
// Reference: http://www.blackdogfoundry.com/blog/moving-repository-from-bitbucket-to-github/
// See also: http://www.paulund.co.uk/change-url-of-git-repository
$ cd $HOME/Code/repo-directory
$ git remote rename origin bitbucket
$ git remote add origin https://github.com/mandiwise/awesome-new-repo.git
$ git push origin master
$ git remote rm bitbucket
@talitapagani
talitapagani / navigationTiming-analytics.js
Created May 13, 2014 19:37
How to use Navigation Timing API with Google Analytics
function getPerfStats() {
var timing = window.performance.timing;
return {
dns: timing.domainLookupEnd - timing.domainLookupStart,
connect: timing.connectEnd - timing.connectStart,
ttfb: timing.responseStart - timing.connectEnd,
basePage: timing.responseEnd - timing.responseStart,
frontEnd: timing.loadEventStart - timing.responseEnd
};
}
@larchanka
larchanka / hashcode.js
Last active January 12, 2018 14:50
JavaScript: Java String.hashCode() implementation. Source: http://goo.gl/Hyt1ku
String.prototype.hashCode = function() {
var hash = 0;
try {
if (this.length == 0) return hash;
for (i = 0; i < this.length; i++) {
char = this.charCodeAt(i);
hash = ((hash << 5) - hash) + char;
<p style="text-align: center">Click Start and begin speaking</p>
<canvas id="canvas" width="800" height="256" ></canvas>
<p id="controls">
<input type="button" id="start_button" value="Start">
&nbsp; &nbsp;
<input type="button" id="stop_button" value="Stop">
</p>
<!-- ----------------------------------------------------- -->
@larrybotha
larrybotha / A.markdown
Last active February 7, 2024 15:20
Fix SVGs not scaling in IE9, IE10, and IE11

Fix SVG in <img> tags not scaling in IE9, IE10, IE11

IE9, IE10, and IE11 don't properly scale SVG files added with img tags when viewBox, width and height attributes are specified. View this codepen on the different browsers.

Image heights will not scale when the images are inside containers narrower than image widths. This can be resolved in 2 ways.

Use sed in bash to remove width and height attributes in SVG files

As per this answer on Stackoverflow, the issue can be resolved by removing just the width and height attributes.

@MichalKalita
MichalKalita / Soupis webů s Nette Framework
Last active November 4, 2018 19:31
Update 29.4.2016: zkontrolováno cca 200 000 stránek, podle hlavičky "X-Powered-By"
http://www.100reklam.cz
http://10hvezd.cz
http://12plus12.cz
http://www.17november1989.sk
http://1bazar.sk
http://www.1cfc.cz
http://1cornhill.com
http://1site.cz
http://www.1weby.cz
http://24keys.cz
@dtipson
dtipson / responsive-request-desktop-site.js
Last active February 17, 2024 20:49
How to make responsive sites better respect the "Request a desktop site" feature on modern mobile browsers.
/*
Enable the "Request Desktop Site" functions on mobile chrome (android and iOS) allow users to see desktop layouts on responsive sites. Note that this is distinct from "opt out of mobile!" buttons built into your site: this is meant to work with the browser's native opt-in/opt-out functionality.
Since these functions work, in part, by simply spoofing the user agent to pretend to be desktop browsers, all we have to do is just remember that the browser once claimed to be android earlier in the same session and then alter the viewport tag in response to its fib.
Here's an example viewport tag <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> that we'd be setting to scaleable-yes,max scale=2. That's just an example of something that works on the site I was building: you should customize the "desktop" viewport content setting to whatever works for your site's needs. If you wanted, you could stick this code in the head just after the primary viewport tag so that the br
@tristanlins
tristanlins / Date.toW3CString.js
Last active February 29, 2024 19:44
Date.toW3CString() method to convert date objects into W3C date time format: yyyy-mm-ddThh:ii:ss+zz:zz
/**
* Convert a Date object to a string, according to W3C date time format: yyyy-mm-ddThh:ii:ss+zz:zz
*
* @memberOf Date
* @access public
* @license MIT
* @copyright 2013 Tristan Lins
* @author Tristan Lins <tristan.lins@bit3.de>
* @link https://gist.github.com/tristanlins/6585391
*/
@dg
dg / websocket.html
Created August 11, 2013 15:54
WebSocket communication between PHP and single client
<!doctype html>
<script>
if ("WebSocket" in window) {
var ws = new WebSocket("ws://127.0.0.1:31339");
ws.onopen = function() {
console.log('connected');
};
ws.onerror = function(e) {
@Mikulas
Mikulas / tips.md
Created July 20, 2013 10:58
Github Markdown Hacks

Images

Inline image without link - simply wrap your images with <a></a>, preventing Github from creating its own link.

<a>![your caption](http://placehold.it/350x150)</a>

With link   Without link

Also note that images served over https:// are not cached, which is useful for changing content without actually editing the image url itself. Example: CI status badges