Skip to content

Instantly share code, notes, and snippets.

View FMCorz's full-sized avatar

Frédéric Massart FMCorz

  • Branch Up Pty Ltd
  • Perth, Australia
View GitHub Profile
@FMCorz
FMCorz / sandbox.py
Last active October 2, 2023 12:25
Django standalone script #python #django
# Standalone Django script
#
# Ideal for quickly testing some code.
#
# 1. Place at the root of your project
# 2. Edit the variable PROJECT_NAME
# 3. Run it: python sandbox.py
import os
@FMCorz
FMCorz / .eslintrc.js
Last active February 15, 2018 02:05
Moodle Mobile utilities (watch, eslint, ...)
module.exports = {
"env": {
"browser": true,
"es6": false
},
"extends": "eslint:recommended",
"parserOptions": {
},
"plugins": [
],
@FMCorz
FMCorz / example.php
Created November 13, 2017 04:57
Mocking a static method call
<?php
// Before.
class Db {
public static function query() {
// Do the request.
return $result;
}
}
@FMCorz
FMCorz / store.js
Last active August 4, 2022 10:01
Fallback on cache when Axios reports a network error
import Axios from 'axios';
import { setupCache } from 'axios-cache-adapter';
import exclude from 'axios-cache-adapter/src/exclude';
// Define the cache adapter.
const cacheAdapter = setupCache({
clearOnStale: false,
});
const getKey = cacheAdapter.config.key;

Keybase proof

I hereby claim:

  • I am fmcorz on github.
  • I am fmcorz (https://keybase.io/fmcorz) on keybase.
  • I have a public key ASCJwz5ygJshFrMTAh916fL68F4OdCtWT36TEtbc-LDVcQo

To claim this, I am signing this object:

@FMCorz
FMCorz / file.php
Created September 27, 2017 05:59
Rest API
<?php
function get_routes() { return [
[
'regex' => '/courses',
'methods' => [
'GET' => [
'function' => 'core_course_get_courses'
],
'POST' => [
'function' => 'core_course_create_courses',
@FMCorz
FMCorz / test.sh
Created May 18, 2017 02:33
Webservice test for duplicating Moodle courses
#!/bin/bash
API="http://10.1.1.13/sm/webservice/rest/server.php" # WS entry point.
COURSEID=25 # Course to duplicated.
CATEGORYID=1 # Category to duplicate to.
TOKEN="490b48f8cd71e88a37fa70cc6eff3fb2" # WS Token.
# SCRIPT STARTS HERE.
SUFFIX=`date +"%s"`
@FMCorz
FMCorz / setup.md
Last active September 8, 2021 09:51
Sublime Text, Django and Pylint

Pre-requisites

  • Install SublimeLinter
  • Install SublineLinter-pylint

Global pylint

Install pylint globally.

@FMCorz
FMCorz / es5.js
Last active August 24, 2016 07:28
Extending (or overriding) class methods in Javascript
// This is a parent class.
var MyParentClass = function() {};
MyParentClass.prototype.myMethod = function() {
this.i++;
return this.i;
};
// Make new class.
var MyChildClass = function() {
// Call the parent constructor.
/** Using scssphp */
error, pre seriousError, span seriousError, other, hello {
border: 1px #f00;
background-color: #fdd; }
pre seriousError, span seriousError {
font-size: 20px; }
hello {
color: green; }