My Javascript study notes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python 2.7 | |
# 1. Iterator | |
def f(n): | |
return [x**4 for x in range(n)] | |
def f2(n): | |
for x in range(n): | |
yield x**3 | |
# Check if is a prime | |
def isPrime(n): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Hero} from './hero'; | |
import {HEROES} from './mock-heroes'; | |
import {Injectable} from 'angular2/core'; | |
@Injectable() | |
export class HeroService { | |
getHeroes() { | |
return Promise.resolve(HEROES); | |
} | |
// See the "Take it slow" appendix | |
getHeroesSlowly() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main (main) where | |
import Control.Monad (forever, when) | |
import System.Environment (getArgs) | |
import System.IO (withBinaryFile, hIsEOF, IOMode(ReadMode), hSetBuffering, BufferMode(BlockBuffering)) | |
import Control.Concurrent (threadDelay) | |
import Blaze.ByteString.Builder.ByteString (fromByteString) | |
import Data.ByteString (ByteString) | |
import Data.ByteString as BS | |
import Data.Text as T |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(window, undefined) { | |
var SITE_ID = null; | |
var NETLIFY_API = "https://api.netlify.com"; | |
var NetlifyError = function(err) { | |
this.err = err; | |
}; | |
NetlifyError.prototype.toString = function() { | |
return this.err.message; | |
}; | |
var authWindow, base, providers; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
import matplotlib.pyplot as plt | |
# show diff | |
# Approach 0 | |
img = cv2.imread('messi4.jpg') | |
b,g,r = cv2.split(img) | |
img2 = cv2.merge([r,g,b]) | |
plt.subplot(121);plt.imshow(img) # expects distorted color | |
plt.subplot(122);plt.imshow(img2) # expect true color |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
from matplotlib import pyplot as plt | |
# show gray image | |
plt.imshow(img, cmap=plt.get_cmap('gray')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import httplib2 as http | |
import json | |
try: | |
from urlparse import urlparse | |
except ImportError: | |
from urllib.parse import urlparse | |
headers = { | |
'Accept': 'application/json', |
My Python study notes.
My Java study notes.
OlderNewer