程序員如何在工作后找到女朋友?(文末有彩蛋)
生活中我們常常發現很多程序員拿著高薪,卻常常淪為單身狗,每當情人節來臨,卻只能形單影只的一個人,過得十分凄慘。
自從程序員畢業出來工作進入 IT 行業之后,常常接觸不到女性,一不小心就到了被催戀催婚的年紀。
前有阿里的高級工程師,穿著一雙特步的運動鞋去相親,結果被對方婉拒。后有某程序員自爆去相親,卻帶著相親對象吃 79 塊的肯德基,結果回去后就被妹子拉黑了。
程序員們常常是大家調侃的對象,是因為他們每天與機器為伍,和電腦打交道,給人們留下的印象是宅,木訥,不善交流......
據說世界上有 2 種程序猿,一種是有女朋友的程序猿,另一種是不知道別的程序猿是怎么找到女朋友的程序猿。
那些有女朋友的程序員都是怎么找到女朋友的呢?讓我們一起來看下網友們怎么說。
程序員如何在工作后找到女朋友?
@知乎 小醬油
@知乎 楊锘
@知乎 程序員大叔
@知乎 禹程
@知乎 卡拉迦迪斯
其實,除了宅,近乎完美的高薪程序員為什么會至今單身呢?這個問題一直沒找到一個合理的解釋。那么,就先讓我們一起來看下面這個故事!
程序員們為什么不追女生了?
程序員們為什么不追女生了?當然是因為,女朋友哪有代碼好看,女朋友哪有基友懂我,女朋友老管我,為什么要有女朋友。
對不起我撒謊了,為什么撒謊,容我先講個故事。
3 個月前,我發送了一個請求給一見鐘情的姑娘,沒想到她很快地響應了數據。
在交互了一個月,傳遞了一些參數后,最終我鼓起勇氣,發送一個新請求。
沒有響應,再次請求,再三請求,她還是響應了個 404,我覺得我的路徑有問題。
能 ping 得通,就是訪問不了,怪事!于是我決定使用閨蜜這個代理服務器,閨蜜建議我換參數,比如某款香水。
這次立即給我響應了,登上主頁面提示我提交數據,她則返回了空結果作為響應,于是我傳了更多的參數,并再一次發出了請求。
這次她顯示權限不足,依然 404。我找了基友,幫忙一起找 Bug,但在找我的 Bug 過程中,發現有好幾個人同時在給她發請求,但都得到響應了。
有的甚至已經開通白名單,原來 Server 端并不是不能處理并發,而是直接忽略了我的請求。
最后我恍然大悟,原來是 CPU、顯卡性能不夠,只能當備用,怪不得頻頻響應數據,接受參數,卻一個功能都用不了。
最終我花了差不多 10K,但我意識到該及時止損了,最后當我狠心卸載的時候,她還百般挽留,讓我對服務進行評價...
過幾天,別人建議我試試訪問閨蜜這個代理地址,傳遞同樣的參數,說不定就通了,性能更優。但我沒有這么做,因為即使在這炮火連天的社會,我也不想變成,女生口誅筆伐的渣男。
幸運的是,我沒有等到“我一直把你當朋友啊”這個觸發事件才終止請求,但最終因才疏學淺,無法處理這種高并發問題,更不能保證線程安全,在考慮到時間、空間,及個人精力問題后,只能選擇放棄。
前幾天,突然看到了一條朋友圈,一位擁有著萌萌頭像的姑娘說:“為什么男生總是追到一半就不追了?”
What?一半?你特么給個進度條啊?怎么會有女生覺得自己就應該一直被追到底啊?!對不起,這種事情對被追求者來說是一半,對追求者來說是已經結束了。
你不喜歡我,我心里不承認,你嘴上不承認后來我想明白了,我并不欠你的。
我并不想因為挫折就學套路,因為很多事情告訴我,世界上最可愛最打動人心的都是那些傻逼,而不是那些牛逼(pi)。
身邊的程序員,都是老實孩子,我們是有點積蓄,但不想當提款機,我付出了真心,也希望收獲真心。
如果你不喜歡我,請直接告訴我,我沒有比特幣,更沒有 208 萬,和你來一次壯志凌云地告別,但我依然相信愛情,只希望,遇見你,就是你!
看完上述這個故事,你有何感想?程序員可能是這個世界上“直男癌” 患者最多的群體之一吧。
但是……你真當他們木訥、死板、死宅、不懂浪漫?開什么玩笑!在 520 之際,小編特地收集了這個程序員專屬的告白方式與大家分享,一起看看程序員用代碼敲出的浪漫吧~
程序員的小浪漫----煙火
完整項目預覽地址:http://lingyouhuiquanla.com/lover/
屬性設計
煙花應有的三個狀態狀態:
- 升空
- 等待炸裂
- 炸裂后
煙花:發射點(x,y),爆炸點(xEnd,yEnd),升空后等待炸裂時間(wait),炸裂后微粒個數(count),煙花半徑(radius)
煙花炸裂后微粒:自身位置(x,y),自身大小(size),自身速度(rate),最大煙花半徑(radius)。
config:為全局變量,以及控制參數,包括畫布寬高,設定煙花屬性等。
設定全局變量
- const config = {
- width: 360,
- height: 600,
- canvases: ['bg', 'firework'],
- skyColor: '210, 60%, 5%, 0.2)',
- fireworkTime:{min:30,max:60},
- //煙花參數本身有默認值 傳入undefined則使用默認參數
- fireworkOpt:{
- x: undefined,
- y: undefined,
- xEnd: undefined,
- yEnd: undefined,
- count: 300, //炸裂后粒子數
- wait: undefined, //消失后 => 炸裂 等待時間
- }
- }
構建微粒類
- class Particle{
- //默認值寫法
- constructor({x, y, size = 1, radius = 1.2} = {}){
- this.x = x;
- this.y = y;
- this.size = size;
- this.rate = Math.random(); //每個微粒移動的速度都是隨機不同的
- this.angle = Math.PI * 2 * Math.random(); //每個微粒的偏移角度
- //每次微粒移動速度分解為橫縱坐標的移動。
- this.vx = radius * Math.cos(this.angle) * this.rate;
- this.vy = radius * Math.sin(this.angle) * this.rate;
- }
- go(){
- this.x += this.vx;
- this.y += this.vy;
- this.vy += 0.02; //重力影響 y越大實際越偏下
- //空氣阻力
- this.vx *= 0.98;
- this.vy *= 0.98;
- }
- //畫出微粒的位置
- render(ctx){
- this.go();
- ctx.beginPath();
- ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2, false);
- ctx.fill();
- }
- }
構建煙花類
- class Firework{
- constructor({x, y = config.height, xEnd, yEnd, count = 300, wait} = {}){
- //煙花自身屬性
- this.x = x || config.width / 8 + Math.random() * config.width * 3 / 4;
- this.y = y;
- this.xEnd = xEnd || this.x;
- this.yEnd = yEnd || config.width / 8 + Math.random() * config.width * 3 / 8;
- this.size = 2;
- this.velocity = -3;
- this.opacity = 0.8;
- this.color = `hsla(${360 * Math.random() | 0},80%,60%,1)`;
- this.wait = wait || 30 + Math.random() * 30;
- //微粒個數等
- this.count = count;
- this.particles = [];
- this.createParticles();
- this.status = 1;
- }
- //創建微粒
- createParticles(){
- for(let i = 0;i < this.count; ++i){
- this.particles.push(new Particle({x:this.xEnd, y:this.yEnd}));
- }
- }
- //升空
- rise(){
- this.y += this.velocity * 1;
- this.velocity += 0.005; //升空時產生的阻力
- //煙花升空到目標位置開始漸隱
- if(this.y - this.yEnd <= 50){
- this.opacity = (this.y - this.yEnd) / 50;
- }
- //如果到了目標位置 就開始第二個狀態
- if(this.y <= this.yEnd){
- this.status = 2;
- }
- }
- //渲染煙花 煙花所有動作完成之后返回false
- render(ctx){
- switch(this.status){
- case 1: //升空
- ctx.save();
- ctx.beginPath();
- ctx.globalCompositeOperation = 'lighter';
- ctx.globalAlpha = this.opacity;
- ctx.translate(this.x, this.y);
- ctx.scale(0.8, 2.3);
- ctx.translate(-this.x, -this.y);
- ctx.fillStyle = this.color;
- ctx.arc(this.x + Math.sin(Math.PI * 2 * Math.random()) / 1.2, this.y, this.size, 0, Math.PI * 2, false);
- ctx.fill();
- ctx.restore();
- this.rise();
- return true;
- break;
- case 2: //煙花消失階段,等待炸裂
- if(--this.wait <= 0){
- this.opacity = 1;
- this.status = 3;
- }
- return true;
- break;
- case 3: //炸裂之后 渲染煙花微粒
- ctx.save();
- ctx.globalCompositeOperation = 'lighter';
- ctx.globalAlpha = this.opacity;
- ctx.fillStyle = this.color;
- for(let i = 0;i < this.particles.length;++i){
- this.particles[i].render(ctx);
- }
- ctx.restore();
- this.opacity -= 0.01;
- return this.opacity > 0;
- break;
- default:
- return false;
- }
- }
- }
放煙花
- const canvas = {
- init: function(){
- //一些屬性的設定 可以不用管
- this.setProperty();
- this.renderBg();
- //循環體 **主要
- this.loop();
- },
- setProperty: function(){
- this.fireworks = [];
- this.width = config.width;
- this.height = config.height;
- this.fireworkTime = (config.fireworkTime.min + (config.fireworkTime.max - config.fireworkTime.min) * Math.random()) | 0;
- this.bgCtx = document.querySelector('#bg').getContext('2d');
- this.fireworkCtx = document.querySelector('#firework').getContext('2d');
- },
- renderBg(){
- this.bgCtx.fillStyle = 'hsla(210, 60%, 5%, 0.9)'
- this.bgCtx.fillRect(0, 0, this.width, this.height);
- },
- loop(){
- requestAnimationFrame(this.loop.bind(this));
- this.fireworkCtx.clearRect(0, 0, this.width, this.height);
- //隨機創建煙花
- if(--this.fireworkTime <= 0){
- this.fireworks.push(new Firework(config.fireworkOpt));
- //每次到點之后重新設置煙花產生時間 (|0轉化為整數)
- this.fireworkTime = (config.fireworkTime.min + (config.fireworkTime.max - config.fireworkTime.min) * Math.random()) | 0;
- }
- for(let i = this.fireworks.length - 1; i >= 0; --i){
- //渲染煙花 (若返回值為false則移除煙花)
- !this.fireworks[i].render(this.fireworkCtx) && this.fireworks.splice(i,1);
- }
- }
- }
- canvas.init();
完善
此時煙花是這樣的,感覺少了點小尾巴。
現在我們每一幀都是清除了畫布,如果要加上小尾巴其實也很簡單,每一幀都不要清除畫布,而是覆蓋一層新的有透明度的天空上去。
- //canvas.loop方法
- // this.fireworkCtx.clearRect(0, 0, this.width, this.height);
- this.fireworkCtx.fillStyle = config.skyColor;
- this.fireworkCtx.fillRect(0,0,this.width,this.height);
這時就變成這樣了。但是,還是缺少了在爆炸瞬間天空變亮的場景。那么在畫煙花的時候,先會獲取一下煙花的顏色以及透明度。
- // *****Firework constructor
- // this.color = `hsla(${360 * Math.random() | 0},80%,60%,1)`;
- this.hue = 360 * Math.random() | 0;
- this.color = `hsla(${this.hue},80%,60%,1)`;
- // *****Firework 新增實例方法
- getSkyColor(){
- const skyColor = {
- //只有炸裂階段才返回亮度
- lightness: this.status == 3 ? this.opacity : 0 ,
- hue: this.hue
- };
- return skyColor;
- }
- // *****config 修改config的skyColor
- // skyColor: 'hsla(210, 60%, 5%, 0.2)',
- skyColor: 'hsla({hue}, 60%, {lightness}%, 0.2)',
- // canvas.loop方法
- //this.fireworkCtx.fillStyle = config.skyColor;
- //每次替換色調與亮度值。
- this.fireworkCtx.fillStyle = config.skyColor.replace('{lightness}', 5 + this.skyColor.lightness * 15).replace('{hue}' , this.skyColor.hue);
- this.skyColor = { //新增
- lightness: 0,
- hue: 210
- };
- for(let i = this.fireworks.length - 1; i >= 0; --i){
- //新增 天空顏色為最亮的煙花的顏色
- this.skyColor = this.skyColor.lightness >= this.fireworks[i].getSkyColor().lightness ? this.skyColor : this.fireworks[i].getSkyColor();
- !this.fireworks[i].render(this.fireworkCtx) && this.fireworks.splice(i,1);
- }
到現在就算是大功告成了。
完整項目
Github 項目地址:https://github.com/NewNewKing/SmallRomance
留 言 有 禮 活 動
程序員的你會如何浪漫表白呢?掃描下方二維碼,關注51CTO技術棧公眾號。歡迎在技術棧微信公眾號留言探討。小編將精選出最有價值的三條評論,分別獲得 50、30、20 元 的 紅 包 獎 勵,活動截止時間 5 月 25 號 12 時整。