Skip to content

Instantly share code, notes, and snippets.

View AdrianSkar's full-sized avatar
:octocat:

Adrian Skar AdrianSkar

:octocat:
View GitHub Profile
@AdrianSkar
AdrianSkar / main.c
Last active June 20, 2024 14:09
[GNL]: main for printf segfault on EOF
#include "get_next_line.h"
#include <stdio.h> // printf
#include <fcntl.h> // open, O_RDONLY, O_WRONLY, O_RDWR,
int main(void)
{
int gnl_calls = 3, fd, i;
char *line;
fd = open("test.txt", O_RDONLY);
@AdrianSkar
AdrianSkar / c-selection-sort.c
Created May 9, 2024 16:30
selection sort in C
# include <stdio.h>
// selection sort example
void ft_ssort_arr(int *arr, int size)
{
int i = 0, j; // arr indexes
int min; // index of the minimum value
int temp; // temporary variable to store the value of the array
while (i < size-1) // arr iter
@AdrianSkar
AdrianSkar / c-bubble-sort.c
Last active May 9, 2024 11:55
bubble sort in C
# include <stdio.h>
// bubble sort example
void ft_sort_arr(int *arr, int size)
{
int passes = 0; // number of passes
int j; // index of the array
int temp; // temporary variable to store the value of the array
int swap_count = -1; // number of swaps in each pass, -1 to enter the loop
@AdrianSkar
AdrianSkar / rev-names.js
Created October 16, 2022 15:39
reversed and sortered Array of names
const people = [
'Bernhard, Sandra',
'Bethea, Erin',
'Becker, Carl',
'Bentsen, Lloyd',
'Beckett, Samuel',
'Blake, William',
'Berger, Ric',
'Beddoes, Mick',
'Beethoven, Ludwig',
@AdrianSkar
AdrianSkar / trakt-backup.php
Created January 22, 2022 16:25 — forked from darekkay/trakt-backup.php
Trakt.tv backup script
<?php
/*
Backup script for trakt.tv (API v2).
Live demo: https://darekkay.com/blog/trakt-tv-backup/
*/
// create a Trakt app to get a client API key: http://docs.trakt.apiary.io/#introduction/create-an-app
$apikey = "CLIENT_API_KEY";
@AdrianSkar
AdrianSkar / array.entries.js
Created May 28, 2021 14:37
[JS] Array.entries()
const arr = ['html', 'css', 'js'];
const iter = arr.entries();
for (let value of iter) {
console.log(value); // [ 0, 'html' ], [ 1, 'css' ], [ 2, 'js' ]
}
@AdrianSkar
AdrianSkar / forEach.js
Created May 28, 2021 14:15
[JS] Array.forEach()
const arr = ["html", "css", "js"];
arr.forEach(ele => {
console.log(ele); // html, css, js
});
@AdrianSkar
AdrianSkar / zoomInBrowser.js
Last active May 29, 2020 14:55
Reveal a button to run a Zoom meeting in the browser without having to clic on download first.
window.addEventListener("load", function(){
var curU = window.location.href; // get current URL
var newU = curU.replace('/j/', '/wc/join/'); // Set URL for running metting in the browser
var browMe = document.createElement('a');
browMe.setAttribute('href', newU);
browMe.innerHTML = 'Run in browser';
document.querySelector('div[role="main"]').appendChild(browMe); // Add button to Zoom's content
});
@AdrianSkar
AdrianSkar / toggleMSVendorsOutlook.js
Last active December 27, 2019 17:51
Toggle off Outlook advertising vendors
// https://stackoverflow.com/questions/2705583/how-to-simulate-a-click-with-javascript
function eventFire(el, etype){
if (el.fireEvent) {
el.fireEvent('on' + etype);
} else {
var evObj = document.createEvent('Events');
evObj.initEvent(etype, true, false);
el.dispatchEvent(evObj);
}
}
@AdrianSkar
AdrianSkar / main.js
Created September 2, 2018 11:01
Comparison with the equality operator created by AdrianSkar - https://repl.it/@AdrianSkar/Comparison-with-the-equality-operator
function testEqual(val) {
if (val == 12) { // Change this line
return "Equal";
}
return "Not Equal";
}
// Change this value to test
testEqual(10);