Skip to content

Instantly share code, notes, and snippets.

@rday
rday / notes-slide.py
Last active July 27, 2017 00:53
python pptx notes slide
"""
Example of accessing the notes slides of a presentation.
Requires python-pptx 0.5.6 or later.
ryan@ryanday.net
"""
from pptx.util import lazyproperty, Pt
from pptx.parts.slide import BaseSlide, Slide, _SlideShapeTree, _SlidePlaceholders
from pptx.shapes.shape import BaseShape
@chezou
chezou / visword2vec.py
Last active December 2, 2020 20:52
Visualizer word2vec data for ipython notebook
# -*- coding: utf-8 -*-
"""
given a word and visualize near words
original source code is https://github.com/nishio/mycorpus/blob/master/vis.py
"""
import word2vec_boostpython as w2v
from sklearn.decomposition import PCA
import matplotlib.pyplot as plt
import matplotlib.font_manager
@supinf
supinf / s3-invalidation.js
Last active January 7, 2023 08:57
AWS Lambda script:: CloudFront Invalidations which are triggered by s3 events.
console.log('Loading event');
var Q = require('q');
var aws = require('aws-sdk');
var cloudfront = new aws.CloudFront();
exports.handler = function (event, context) {
//_log('Received event: ', event);
var bucket = event.Records[0].s3.bucket.name;
@drgarcia1986
drgarcia1986 / __main__.py
Last active August 9, 2023 21:20
Example of OAuth2 autentication server with Client Credentials grant (using python-oauth2 and tornado)
# !/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Diego Garcia'
import tornado.web
import tornado.ioloop
import oauth2.tokengenerator
import oauth2.grant
import oauth2.store.redisdb
import oauth2.store.mongodb
@Akiyah
Akiyah / jibanyan_equation
Created November 12, 2014 00:28
jibanyan_equation
jibanyan_equation <- function(x,y) {
min(max(min(1-(x/108)^2-(y/94)^2,y),min(1-((abs(x)-119)/103)^2-((y-56)/86)^2,1-((abs(x)-15)/77)^2-((y-119)/100)^2),1-((abs(x)-42)/66)^2-(y/55)^2,min(55+y,51-abs(x),-y)),3*abs(y-100)-2*(x-75)) *
min(min(max(min(1-(x/106)^2-(y/92)^2,y),min(1-((abs(x)-119)/101)^2-((y-56)/84)^2,((abs(x)-99)/40)^2+((y-54)/86)^2-1,92-abs(x)),1-((abs(x)-42)/64)^2-(y/53)^2),min(((abs(x)-52)/26)^2+((y+28)/26)^2-1,((abs(x)-51)/13)^2+(y/13)^2-1,max(abs(x)-51,y))),abs(x/51+10/51*sin(abs(y/61.2)^(1.2)*pi*(7/2)))^(2/3)+abs(y/61.2)^(2/3)-1) *
min(1-(x/32)^2-((y+30)/32)^2,1-((abs(x)+5)/22)^2-((y-18)/22)^2) *
min(1-((abs(x)-18)/20)^2-((y+10)/20)^2,((abs(x)-20)/22)^2+((y+7)/20)^2-1) *
(1-((abs(x)-51)/11)^2-(y/11)^2)
}
x <- seq(-150, 150, length=400)
z <- outer(x,x, Vectorize(jibanyan_equation))
@koyudoon
koyudoon / pit-0.3_fix-typo.patch
Created May 12, 2014 03:25
patch for pit-0.3(python) to fix a tiny typo
--- pit.py.org 2014-05-01 05:22:27.000000000 +0900
+++ pit.py 2014-05-12 12:06:55.989623817 +0900
@@ -33,7 +33,7 @@
if result == c:
print 'No Changes'
if name in profile:
- return profile[nane]
+ return profile[name]
return
@madjar
madjar / scrapper.py
Last active March 5, 2023 15:02
A example of scrapper using asyncio and aiohttp
import asyncio
import aiohttp
import bs4
import tqdm
@asyncio.coroutine
def get(*args, **kwargs):
response = yield from aiohttp.request('GET', *args, **kwargs)
return (yield from response.read_and_close(decode=True))
var attempts = 1;
function createWebSocket () {
var connection = new WebSocket();
connection.onopen = function () {
// reset the tries back to 1 since we have a new connection opened.
attempts = 1;
// ...Your app's logic...
@nappa7878
nappa7878 / ProgressBar.bas
Last active May 26, 2021 23:27
PowerPointのスライドにプログレスバーを付加するマクロ
Sub MakeProgressBar()
Const r As String = "00" '色・RGB値のR
Const g As String = "99" '色・RGB値のG
Const b As String = "00" '色・RGB値のB
Const pbH As Long = 10 '高さ
Const pbBG As Single = 0.6 '背景の透過性
Dim i As Long
Dim s As Shape
@ikegami-yukino
ikegami-yukino / nfkc_compare.txt
Created December 30, 2013 19:32
Pythonのunicodedata.normalize('NFKC')で正規化される文字の一覧
# -*- coding: utf-8 -*-
import unicodedata
for unicode_id in xrange(65536):
char = unichr(unicode_id)
normalized_char = unicodedata.normalize('NFKC', char)
if char != normalized_char:
if len(normalized_char) == 1:
print u'[%d] %s -> [%d] %s' % (unicode_id, char, ord(normalized_char), normalized_char)
else: