Skip to content

Instantly share code, notes, and snippets.

Avatar

Pavel Vlasov pavelvlasov

View GitHub Profile
View github-pull-reminder-webtask-hack.js
'use strict';
const {promisify} = require('util');
const request = promisify(require('request'));
const Promise = global.Promise;
const getPullRequestsQuery = (owner, name) => {
return `
query GET_REVIEWS_QUERY {
repository(owner:"${owner}", name:"${name}") {
@pavelvlasov
pavelvlasov / player.js
Created Jul 24, 2018
Player component
View player.js
<Container>
<Gun top={15} left={18}>
<Tile src={gun} state={0} tile={{ width: 17, height: 17 }} />
</Gun>
<Sprite
src={sideAnimation}
states={4}
tile={{ width: 20, height: 24 }}
scale={1.5}
framesPerStep={8}
@pavelvlasov
pavelvlasov / animate.js
Created Jul 24, 2018
Sprite animate function
View animate.js
const { state } = this.state;
const { framesPerStep, states } = this.props;
if (this.tick === framesPerStep) {
this.tick = 0;
this.setState({
state: (state + 1) % states
});
}
this.tick += 1;
@pavelvlasov
pavelvlasov / sprite.js
Created Jul 24, 2018
Sprite component
View sprite.js
class Sprite extends React.Component {
static defaultProps = {
src: PropTypes.string.isRequired,
tile: PropTypes.object.isRequired,
scale: PropTypes.number.isRequired
};
tick = 0;
frame: number = 0;
state = {
state: 0
View tile.js
class Tile extends React.Component {
static propTypes = {
src: PropTypes.string.isRequired,
tile: PropTypes.object.isRequired,
state: PropTypes.number.isRequired,
scale: PropTypes.number.isRequired
};
render() {
const { src, tile, state, scale } = this.props;
View image.js
const Image = styled.img`
transform: translate(-${({ left }) => left}px, 0);
`;
@pavelvlasov
pavelvlasov / container.js
Last active Jul 24, 2018
Sprite container
View container.js
const Container = styled.div`
width: ${({ width }) => width}px;
height: ${({ height }) => height}px;
overflow: hidden;
transform: scale(${({ scale }) => `${scale}, ${scale}`});
transform-origin: top left;
`;
View slack_handler.ts
callback(null, { body: "OK", statusCode: 200 });
const message = mentionEvent.text;
const parts = repoRegExp.exec(message);
if (parts) {
const repo = parts[1];
const params = {
FunctionName: `${stage}-getContributorStatsImage`,
InvocationType: "RequestResponse",
View serverless.js
const baseConfig = require('../../serverless.base');
const { defaultsDeep } = require('lodash');
module.exports = defaultsDeep(
{
service: 'git-stats',
provider: {
iamRoleStatements: [
...baseConfig.provider.iamRoleStatements,
@pavelvlasov
pavelvlasov / serverless.js
Created Jan 21, 2018
html to png serverless.js
View serverless.js
const baseConfig = require('../../serverless.base');
const { defaultsDeep } = require('lodash');
module.exports = defaultsDeep(
{
service: 'html-to-png',
functions: {
renderToPng: {
name: '${self:provider.stage}-renderToPng',
handler: 'index.handler',
You can’t perform that action at this time.