Skip to content

Instantly share code, notes, and snippets.

Matteo Capucci mattecapu

Block or report user

Report or block mattecapu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mattecapu
mattecapu / c_cheatsheet.c
Last active Jan 18, 2017
List of commonly used idioms
View c_cheatsheet.c
// alias type to new_name
typedef type new_name;
// declare an array
int vector[SIZE];
// declare an array, size undetermined
int vector[] = { 3, 4 };
void read_str( char s[] );
// main signature
View library.jsx
export default class Library extends React.Component {
static getFragment() {
return Lokka.getFragment(`
fragment on Library {
name
}
`);
}
render() {
View app.jsx
import Library from '../components/library';
export default class App extends React.Component {
static async getInitialProps() {
return await Lokka.query(`{
libraries {
id,
...${Library.getFragment()}
}
}`);
View lokka_singleton.js
import { Lokka } from 'lokka';
import { Transport } from 'lokka-transport-http';
import { SERVER_URL } from '../config';
/* singleton Lokka client */
export default new Lokka({
transport: new Transport(`${SERVER_URL}/graphql`)
});
View .babelrc
{
"presets": [
"next/babel"
]
}
View build.json
"start": "node dist/server.js",
"clean": "rm -rf dist",
"prebuild": "npm run clean && mkdir dist && cp -r src/** dist/",
"build": "babel src --ignore pages/*,components/* -d dist && next build dist",
View koa.sh
yarn add koa@2 koa-graphql koa-router@next koa-convert --exact
View graphql.sh
yarn add graphql lokka lokka-transport-http --exact
View seq.sh
yarn add sequelize pg pg-hstore --exact
View setup.sh
mkdir libradar
cd libradar
git init
yarn init
yarn add next --exact
mkdir pages components
You can’t perform that action at this time.