Skip to content

Instantly share code, notes, and snippets.

View crimson-med's full-sized avatar
🎃
Boo

Burlet Médéric crimson-med

🎃
Boo
View GitHub Profile
@crimson-med
crimson-med / HandlingNotification.js
Created November 29, 2017 04:49
Handle actions through fcm push
OPTManager(){
AsyncStorage.setItem('myProfile_OTP', "true").catch(erop =>{
console.error(erop)
});
DeviceEventEmitter.emit('refreshOTP', "true")
}
componentWillMount{
FCM.getInitialNotification().then(notif => {
if(notif.click_action == "OTP RENEW"){
this.OPTManager();
@crimson-med
crimson-med / updateParentID.php
Created December 8, 2017 10:01
Updating wordpress parent ID with proper linking in term_taxonomy using wp_update_term
<?php
//localID is the termID you want to change
//parentLocalID is the parent term ID you want to put
function updateParentID($localID, $parentLocalID){
global $wpdb;
$table_name = $wpdb->prefix.'term_taxonomy';
$value = wp_update_term( $localID, 'product_cat', array( 'parent' => $parentLocalID ) );
if ( is_wp_error( $value ) ) {
return $value->get_error_message();;
}else {
@crimson-med
crimson-med / relatedPosts.php
Created December 13, 2017 04:26
A simple related posts function to get posts by categrory in wordpress
@crimson-med
crimson-med / detectMobile.js
Created January 25, 2018 04:50
An easy way to check if we are on mobile in jQuery
$( document ).ready(function() {
var isMobile = window.matchMedia("only screen and (max-width: 760px)");
if (isMobile.matches) {
//Conditional script here
console.log("We are on mobile").
}
});
@crimson-med
crimson-med / maps.json
Created April 2, 2018 16:36
Dofus maps sorted by world with backgrounds
{
"1": {
"id": 1,
"origineX": 6480,
"origineY": 4944,
"mapWidth": 69.5,
"mapHeight": 49.700001,
"horizontalChunck": 5,
"verticalChunck": 4,
"viewableEverywhere": true,
@crimson-med
crimson-med / nested_render.pug
Created April 9, 2018 13:25
Example of nested render in Pug (@JADE)
table
tbody
each world in json
if world.id == 1
- var row = world.maps[0].posY
tr
each map in world.maps
if row == map.posY
td
// img.className#IdName(src=map.background alt="Image Title")
@crimson-med
crimson-med / nodeProgressBar.js
Created April 25, 2018 11:02
a simple rendering of a progress bar for node environment
renderProgressBar: async function (currentValue, totalValue){
process.stdout.clearLine(); // clear current text
process.stdout.cursorTo(0); // move cursor to beginning of line
let percent = ((currentValue)/totalValue*50).toFixed(2) ;
let progressFirst = "";
let progressLast = "";
for (let j = 0; j < 50; j++) {
if (j <= percent) {
progressFirst = progressFirst + "=";
}else{
namespace YourProject.YourForlder
{
using System;
using YourProject.Abstractions.Interfaces;
public static class MessageParser
{
public static bool TryParse(IReader reader, out int messageId, out int dataLength, out byte[] data)
{
messageId = 0;
! function t(e, r, n) {
function i(a, s) {
if (!r[a]) {
if (!e[a]) {
var u = "function" == typeof require && require;
if (!s && u) return u(a, !0);
if (o) return o(a, !0);
var c = new Error("Cannot find module '" + a + "'");
throw c.code = "MODULE_NOT_FOUND", c
}
@crimson-med
crimson-med / splashscreen.js
Created September 21, 2018 10:19
React Native Splashscreen
import React, {Component} from 'react';
import { Modal, View, Text, Image } from 'react-native';
export default class Splashscreen extends Component {
constructor () {
super()
}
render() {