Skip to content

Instantly share code, notes, and snippets.

@smmoosavi
smmoosavi / puppeteer-graphql.js
Last active February 15, 2022 22:06
GraphQL schema to select html elements
var { graphql, GraphQLSchema, GraphQLString, GraphQLObjectType, GraphQLNonNull, GraphQLList } = require('graphql');
// root query
const RootQuery = new GraphQLObjectType({
name: 'RootQuery',
fields: () => QueryFields,
});
const QueryFields = {};
@smmoosavi
smmoosavi / cssbattle.html
Created October 7, 2021 15:56
cssbattle
<div class="grid g"></div>
<div class=""></div>
<style>
body {
background: #6592CF;
}
.grid {
position: absolute;
top: 0px;
@smmoosavi
smmoosavi / svelte-routing.d.ts
Last active February 17, 2021 18:36
svelte-routing typings
declare module 'svelte-routing' {
import { SvelteComponent, SvelteComponentTyped } from 'svelte';
interface LinkProps {
to: string;
replace?: boolean;
state?: {
[k in string | number]: unknown;
};
getProps?: (linkParams: GetPropsParams) => Record<string, any>;
{
"dependencies": {
"@jaebradley/fruit": "^1.0.20",
"@nrwl/cli": "^9.4.1",
"@persper/js-callgraph": "^1.3.2",
"@storybook/cli": "^5.3.17",
"@typescript-eslint/eslint-plugin": "^2.13.0",
"cloc": "^2.5.1",
"commitizen": "^4.0.3",
"conventional-changelog-cli": "^2.0.23",
type ComponentProps<C> = C extends React.ComponentType<infer P> ? P : any;
@smmoosavi
smmoosavi / jalaaliUtils.js
Created March 15, 2018 16:39
material-ui-pickers-jalaali-utils
import jMoment from 'moment-jalaali'
import { toPersian } from './toPersian'
export default class jalaaliUtils {
static toJMoment (date) {
return jMoment(date ? date.clone() : undefined)
}
static parse (value, format) {
return jMoment(value, format)
@smmoosavi
smmoosavi / README.md
Last active November 21, 2017 19:15
list of questions for publishing npm package

what packages we need?

eslint

  • eslint
  • eslint-config-airbnb
  • eslint-plugin-import
  • eslint-plugin-jsx-a11y
  • eslint-plugin-react

.eslintrc

@smmoosavi
smmoosavi / code.py
Last active December 27, 2017 11:11
graphql example
@classmethod
def mutate_and_get_payload(cls, input, context, info):
user = context.user
old_password = input.get('old_password')
new_password = input.get('new_password')
if user.has_usable_password():
if not user.check_password(old_password):
raise ResponseError(
"Invalid Password",
@smmoosavi
smmoosavi / Exceptions.py
Created May 26, 2017 06:38
graphene-django custom error and better error handling
class ResponseError(Exception):
def __init__(self, message, code=None, params=None):
super().__init__(message)
self.message = str(message)
self.code = code
self.params = params