Skip to content

Instantly share code, notes, and snippets.

@agektmr
agektmr / ws_echo_server
Created August 6, 2012 09:28
ws echo server
var WebSocket = require('ws').Server;
var ws = new WebSocket({port:8080});
var conn = [];
// Start accepting WebSocket connection
ws.on('connection', function(socket) {
// Add socket to list
conn.push(socket);
broadcast('1 peer connected.');
@agektmr
agektmr / gist:5917056
Created July 3, 2013 11:05
Angular controller inheritance example
<!DOCTYPE html>
<html ng-app>
<head>
<title>Angular Example</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="styles/style.css">
<script src="scripts/angular.min.js"></script>
<script>
var ListCtrl = function($scope) {
$scope.list = [
@agektmr
agektmr / gif animation using html5
Last active September 16, 2022 08:13
How to create gif animation
<html>
<head>
<style>
figure {
width: 200px;
height: 150px;
text-align: center;
float: left;
}
img {
if (DEBUG === undefined) DEBUG = true;
DEBUG && console.log('test');

Managing HTML5 Offline Storage

HTML5 introduced many storage APIs that let you store a large amount of data locally in your users' browsers. But the amount of space allocated for each app is, by default, restricted to a few megabytes. Google Chrome lets you ask for a larger storage quota, beyond the previous limit of just 5 MB.

This document introduces you to the basic concepts around the types of storage used in Chrome and describes the experimental Quota Management API, which lets you manage your storage quota. The document assumes that you are already familiar with the general concepts of client-side storage and know how to use offline APIs.

Contents

@agektmr
agektmr / Getting $promise as a result of $resource.js
Last active August 29, 2015 13:57
I'm getting $promise as a result for fetching css using $resource. Does anyone know how to resolve?
var app = angular.module('app', ['ngResource']);
app.service('fetch', ['$resource', function() {
return $resource('css/:id/:file_name', {id: '@id'}, {
'get': {
method: 'GET',
params: {
file_name: 'style.css'
}
}
}
@agektmr
agektmr / Apps Script to insert Atom Feed into Google Spreadsheet
Last active September 16, 2021 21:41
This script will fetch an Atom feed and insert rows on top in descending order. Make sure to replace with arbitrary URLs on 2 placeholders.
function main() {
var ss = SpreadsheetApp.openByUrl('YOUR SPREADSHEET URL COMES HERE');
var sheet = ss.getSheets()[0];
var property = PropertiesService.getDocumentProperties();
var last_update = property.getProperty('last_update');
last_update = last_update === null ? 0 : parseFloat(last_update);
var feed = fetch('ATOM FEED URL COMES HERE');
var items = getItems(feed);
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
@agektmr
agektmr / list_of_web_music_hackathons.md
Last active August 29, 2015 14:21
List of Web Music Hackathons
@agektmr
agektmr / Twitter Like
Last active November 6, 2015 14:56
Copy and paste this code to your browser URL bar. (URLバーにコピペしてね)
data:text/html,<script>i=0;setInterval(function(){i=(i+100)%252000;document.querySelector('div').style.backgroundPositionX='-'+i+'px';},30);</script><div%20style="width:100px;height:100px;background:url(https://goo.gl/6nq9n5)">