Skip to content

Instantly share code, notes, and snippets.

View noximus's full-sized avatar
🪄
Making Magic Happen

Nox noximus

🪄
Making Magic Happen
View GitHub Profile
@noximus
noximus / react-gtm-module.js
Created October 28, 2022 15:19
React Google Tag Manager react-gtm-module snippets
// react-gtm-module setup
import TagManager from 'react-gtm-module';
const tagManagerArgs = {
gtmId: 'GTM-XXXXXXX',
};
TagManager.initialize(tagManagerArgs);
// react-gtm-module event
const dataLayer = window.dataLayer || [];
dataLayer.push({
query findCompany {
apple: company(id: "2") {
...companyDetails
}
google: company(id: "1") {
...companyDetails
}
}
fragment companyDetails on Company {
@noximus
noximus / StringPrototypeAna.js
Created August 15, 2020 14:13
This is to show how to make a simple String Prototype for an anagram.
String.prototype.sortLetters = function() {
return this.toLowerCase().split('').sort().join('');
}
var isAnagram = function(test, original) {
return test.sortLetters() == original.sortLetters();
};
// This is to show how to make a simple String Prototype for an anagram.
@noximus
noximus / axios-hook.js
Created June 20, 2020 16:02
Axios & Hooks
function Nox() {
const [data, setData] = React.useState({});
React.useEffect(() => {
axios.get('/nox-daily-message').then(({ data }) => {
setData(data);
});
}, []);
return data.ywmib ? <strong>{data.ywmib}</strong> : <div>Loading...</div>
import CommentBox from "../CommentBox";
it("shows a comment box ", () => {
// make a div
const div = document.createElement("div");
// shows the div we created
ReactDOM.render(<App />, div);
// Looks inside the div
function perimeter(num) {
let a = 1,
b = 0,
temp,
arr = [];
while (num >= 0) {
temp = a;
a = a + b;
b = temp;
arr.push(b);
function numberToDashes(num) {
let array = [];
for (let i = 0; i < num; i++) {
const element = array.push("-");
}
return array.join('')
}
function numToDashes(num) {
return "-".repeat(num);
}
function copyAndSortNumbers(numbers) {
return numbers.concat().sort();
}
/* Do not modify code below this line */
const original = [1, 7, 3, 5];
const sortedCopy = copyAndSortNumbers(original);
console.log(original, '<-- should be [1, 7, 3, 5]');
function getAverageTestScore(scores) {
var total = 0;
for (var i = 0; i < scores.length; i++) {
total += scores[i];
}
const avg = total / scores.length;
// const avg = scores.reduce((a, b) => a+b )/ scores.length;
return avg
@noximus
noximus / hex.css
Last active April 3, 2019 16:13
hex with bells and whistles
.hexagon {
position: relative;
width: 100px;
height: 57.74px;
background-color: #6a08ca;
margin: 28.87px 0;
box-shadow: 0 0 20px rgba(222,189,255,0.45);
border-left: solid 4px #333333;
border-right: solid 4px #333333;
}