Skip to content

Instantly share code, notes, and snippets.

View NurElHuda's full-sized avatar

Nour Tine NurElHuda

View GitHub Profile
@projjal1
projjal1 / fifo.c
Created May 13, 2020 13:38
FIFO Page Replacement Algorithm Implementation in C
#include<stdio.h>
void fifo(int string[20],int n,int size)
{
//Creating array for block storage
int frames[n];
//Initializing each block with -1
for (int i=0;i<n;i++)
frames[i]=-1;
@dotspencer
dotspencer / multiple-keys-gitlab.md
Last active March 7, 2024 15:01
Multiple Gitlab accounts with multiple ssh keys

Gitlab won't allow reuse of a public ssh key for multiple accounts. To get around this you need to create a second ssh key for the second account.

Create or modify your ~/.ssh/config file:

# normal                                                                                                                                                                  
Host gitlab.com-work_username
     HostName gitlab.com
     PreferredAuthentications publickey
 IdentityFile ~/.ssh/id_rsa
@raprasad
raprasad / change_password.md
Last active August 14, 2024 20:22
django user; change password from shell

update django password

general changes

To use in dev environments

  • after python manage.py shell
from django.contrib.auth.models import User
@michaelBenin
michaelBenin / sort_requirements.py
Created July 20, 2014 21:48
Sort requirements pip files or requirements.txt for python dependencies
requirements_file = 'base.pip'
requirements = open(requirements_file, 'r')
content = requirements.read().splitlines()
content = list(set(content))
content.sort(key=lambda y: y.lower())
content = '\n'.join(content)
file = open('sorted_'+requirements_file, 'w')
file.write(content)
@bee-keeper
bee-keeper / Django: Programmatically add permissions to groups
Created March 29, 2014 16:57
Django: Programmatically add permissions to groups
content_type = ContentType.objects.get(app_label='', model='')
#get all permssions for this model
perms = Permission.objects.filter(content_type=content_type)
group = Group.objects.get(name='')
for p in perms:
group.permissions.add(perms)
@kipanshi
kipanshi / gist:3859962
Created October 9, 2012 16:43
Django refresh and update model instance helpers
def refresh(instance):
"""Select and return instance from database.
Usage: ``instance = refresh(instance)``
"""
return instance.__class__.objects.get(pk=instance.pk)
def update(instance, **data):