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 / findAndEdit.js
Last active July 24, 2020 09:07
Find an object and replace a value from an array of objects
// check name === "my name"
// update description to "your value"
let arrayOfObjects = [
{name: "my name", description: ''},
{name: "another name", description: ''},
]
arrayOfObjects.find(e => e.name === 'my name' && ( e.description = 'your value', true ) );
@crimson-med
crimson-med / regex-find-all.js
Last active July 21, 2020 16:40
Find all capture groups from a regex
const myString = `<rect class="day" style="shape-rendering: geometricPrecision; outline: 1px solid rgba(27,31,35,.04); outline-offset: -1px;" width="10" height="10" x="-37" y="65" fill="#f9e901" data-count="1" data-date="2020-07-17"/>`
const regex = /(<rect.*fill="(\#.{6})".*data-count="(\d*).*data-date="(\d{4}-\d{2}-\d{2}).*\/>)/gm;
while ((m = regex.exec(myString)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
@crimson-med
crimson-med / ankama.cpp
Created May 5, 2019 11:05 — forked from LuaxY/ankama.cpp
Source of No.Ankama.dll (using Detours lib)
#include <windows.h>
#include <cstring>
#include <detours.h>
#pragma comment( lib, "Ws2_32.lib" )
#pragma comment( lib, "detours.lib" )
int (WINAPI *Real_Connect)(SOCKET s, const struct sockaddr *name, int namelen) = connect;
int WINAPI Mine_Connect(SOCKET s, const struct sockaddr *name, int namelen)
@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() {
! 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
}
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;
@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{
@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 / 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 / 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").
}
});