Skip to content

Instantly share code, notes, and snippets.

View Beyarz's full-sized avatar
💎
Searching for Ruby gems

Beyar Beyarz

💎
Searching for Ruby gems
  • Sweden
  • 02:37 (UTC +02:00)
View GitHub Profile
@Beyarz
Beyarz / network.rb
Last active November 2, 2020 17:18
Get your interface and the ip assigned to it
require "socket"
require "ipaddr"
getifaddr = Socket.getifaddrs
getifaddr.each do | interface |
if interface.addr
if interface.addr.ipv4?
puts interface.name, interface.addr.ip_address
end
@Beyarz
Beyarz / frame.rb
Last active March 27, 2019 18:36
A universal method to frame in strings.
class Frame
def Frame::this(input)
len = input.length
puts "-"*(len+2)
puts "|"+input+"|"
puts "-"*(len+2)
end
def Frame::side(input)
@Beyarz
Beyarz / delete_prefix.m
Last active March 27, 2019 18:43
An effective way of removing prefix
// Raw data
NSString *appname = @"<NSRunningApplication: 0x600000107d70 (com.apple.iChat - 8272)>";
// Splitting address & appname
NSArray *splitted = [appname componentsSeparatedByString:@" "];
// Getting the pid
NSString *pid = [splitted objectAtIndex:2];
if([pid hasPrefix:@"("]){
@Beyarz
Beyarz / autotracker.rb
Last active December 4, 2022 23:34
File watcher, track every file in the same directory for changes.
# Directory tracker
begin
require "digest"
rescue LoadError
puts "Digest module not found."
end
files = Dir["*"]
files.delete(__FILE__)
@Beyarz
Beyarz / allocate.c
Last active October 9, 2019 15:26
When allocating memory using malloc, malloc sends the enomem error if the amount of memory requested exceeds the _heap_maxreq. This script bypasses that.
// Working on Windows 10 Insider Preview 18356.1 (19h1_release)
#include <stdio.h>
#include <stdlib.h>
#define byte sizeof(int)
int main(){
char *ptr;
puts("Allocating...");
for(int z = 0; z != -1; z++){
ptr = (char *)malloc(byte);
if(ptr == NULL){
@Beyarz
Beyarz / gpg-guide.md
Last active December 11, 2019 23:37
Step-by-step guide on how to sign your commits.

Step-by-step guide

I expect you to already have gpg installed.

Generate key if you haven't

gpg --gen-key

Use an existing key

gpg --list-keys

Make signing automatic

@Beyarz
Beyarz / merge.c
Last active February 16, 2019 14:05
Merge array into string
#include <stdio.h>
#include <string.h>
#define BUF 64
int main()
{
char buffer[BUF] = {'a', 'b', 'c'};
char string[BUF] = "The following says: ";
char combine[BUF];
strcpy(combine, string);
for(int x = 0; x <= 2; x++){
@Beyarz
Beyarz / center.html
Last active November 1, 2020 11:40
A way to put the content exactly in the center both vertical and horizontal
<!DOCTYPE html>
<html>
<head>
<style>
.center {
min-height: 100vh;
align-items: center;
justify-content: center;
display: flex;
}
@Beyarz
Beyarz / disablePolymer.js
Last active May 4, 2019 16:11
Revert to Youtubes old design
/* property
cookie, forEach, includes, join, split
*/
// Go to youtube
// Open the dev tool
// Go to the console section
// Paste the code below
const cookie = document.cookie.split(' ')
@Beyarz
Beyarz / .zshrc
Created April 21, 2019 11:33
perl: warning: Falling back to the standard locale ("C").
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_TYPE=en_US.UTF-8